Ssh without password authentication.
Hello members,
If you want to set some cron for the rsync or scp to other server then you will need to ssh the other server in order to execute the crons or if you want to do ssh it in order to execute perticular command there. If you can ssh to other server without password then this task will be easy for you.
For example you need to copy the file from jason server to jayesh then just do the following steps.
1. The first step is to create a set of public and private keys that uniquely identify your userid on “jason”. Log into jaosn and run the command:
jason% ssh-keygen -t rsa -N ” (This command can take a long time to run on some machines).
The -N ” argument to ssh-keygen specifies that there should be no password associated with these keys. Keys can have passwords just like
accounts, but that would defeat the purpose here.
When it asks you what file you would like to save your key as, you can just press return, to accept the default location. This will create two files on
jason:
jason% ls -l /home/jitu/.ssh/id*
-rw——- 1 jitu jitu 530 Feb 8 18:13 /home/jason/.ssh/id_rsa
-rw-rw-r– 1 jitu jitu 334 Feb 8 18:13 /home/jason/.ssh/id_rsa.pub
The id_rsa file contains the private key (note that it is not world or group readable) that represents your identity on that particular machine. The
private key should never be transferred from the machine or have its modes changed. The id_rsa.pub file is the public key, which is
world-readable. ssh and other programs can use this key to encrypt messages that only you can decrypt using the private key.
2. The next step is give Jason’s public key to jayesh, and tell jayesh that jason is authorized to run remote commands using RSA authentication.
You do this by copying the contents of jason’s id_rsa.pub (not id_rsa!) to a file called authorized_keys in your .ssh directory on jayesh:
jayesh% cd ~/.ssh
jayesh% ssh jason ‘cat .ssh/id_rsa.pub’ >> authorized_keys
Jason’s public key is now in the authorized_keys file on Jayesh, telling jayesh that jason is authorized to use RSA authentication to log in.
By the way, it’s fine to have more than one key in the authorized_keys file, in case you need more than one host to be able to do RSAauthentication to jayesh.
3. The last step is to make sure the authorized_keys file on jayesh has modes 600. This ensures that no one else can view this file.
jayesh% chmod 600 authorized_keys
jayesh% ls -l authorized_keys
-rw——- 1 jitu jitu 662 Feb 8 18:04 .ssh/authorized_keys
You can now ssh from jason to jayesh without using a password.
Enjoy..

















Leave a Reply
You must be logged in to post a comment.