Skip to main content

How to enable key based login in Linux

Following steps will ensure that you can do a ssh/scp command without giving password everytime:

Suppose you have to login from A to B

1. On A:


This will generate a key.

2. On A:

#ssh-copy-id -i ~/.ssh/ <IP of B>

You IP must be different from the above e.g.

#ssh-copy-id -i ~/.ssh/

You will be asked the password of B. I have assumed that ssh port is default, i.e. 22

3. On A:

Test that you have successed by running following command

#ssh <IP of B> e.g.


You can see that we didn't do anything on B.

4. Enjoy !!!!!!!! 


Popular posts from this blog

Tunneling through putty: Accessing a internal website or service outside the network

Hello friends, there are many situation where you have to open a service or website that is neither in your network nor running with a public IP. The site or service is running properly inside the network, but you have to use it outside the network. Is it simple? Yes. 

First you need to download putty.exe. Go, download and then read further. 

All right, let us assume you are working on a local PC, lets say its IP is  There is another website, which you cannot open on your local PC, as this is on different network. If you can access it directly, because of something you have already done, then no need to read further. Lets say you have another server,,  be it different or same as the website hosting server, but it must be on 192.168.3.x network. Then do as below figures:

You will use the port as per the website. In my experience, even if you use any different port, it will work.
Now, put IP of website in destination, port in source port and then add…

Python: Make Standalone EXE for any Python Script


First of all we need to install py2exe. You will find setup files which will install this without any issues.

Find then here:

Make sure to use proper version. If you download a 32 bit version and it says "Python Installation not find in registry, or something like that", then install a 64 bit, as you may have 64 bit python. Act accordingly.

Now we have to check if it is working. Open python console and run like this:

If you see no error, you are good to go.

Now create a folder and make a file inside this folder named as Write any python script there. We will be using below script that prints output 9 times.

for i in range(1, 10):
    print('What have I done !!!!')

Now create another new file with name Write below lines in this file:

from distutils.core import setup
import py2exe


Now open command prompt, navigate to your folder and run below comman…

Python: Create a daemon in Linux to empty log file every 10 seconds

This script will run a daemon and will clear any log mentioned in variable cmd1 every 10 seconds. Two things:

1. You need to install python-daemon to run this.

2. It is not a simple python script, so you can't run it using ./ You have to run it by using ./ start.

3. Again, you can't stop this script by "Ctrl + C" . You have to use./ stop

4. Works with python 2.x


import time
import os
from daemon import runner

class App():
    def __init__(self):
        self.stdin_path = '/dev/null'
        self.stdout_path = '/dev/tty'
        self.stderr_path = '/dev/tty'
        self.pidfile_path =  '/tmp/'
        self.pidfile_timeout = 5
    def run(self):
        while True:
            print "Going to clear log !! "
            cmd1 = 'cat /dev/null > /var/log/mysqld.lo…