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:

#ssh-keygen

This will generate a key.

2. On A:

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

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

#ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.1.51

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.

#ssh 192.168.1.51

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

4. Enjoy !!!!!!!! 

Comments

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 192.168.1.50.  There is another website 192.168.3.33, 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, 192.168.3.110,  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

Hi,

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

Find then here:

http://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/

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 printscr.py. 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 !!!!')
raw_input()


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

from distutils.core import setup
import py2exe

setup(console=['printscr.py'])

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.

https://pypi.python.org/pypi/python-daemon/

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

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

4. Works with python 2.x

-------------------------------------------------------------------------------

#!/usr/bin/python
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/foo.pid'
        self.pidfile_timeout = 5
    def run(self):
        while True:
            print "Going to clear log !! "
            cmd1 = 'cat /dev/null > /var/log/mysqld.lo…