Search This Blog

Friday, June 18, 2010

How to add SSH Keygen

Add keygen to avoid prompting for password while running ssh command.

Type ssh-keygen –t rsa command at Server
When asked to save the file just press enter

[root@ServerHostname .ssh]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
#by default the key is saved in /root/.ssh/id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/
The key fingerprint is:
49:66:a2:5f:73:5f:d4:fc:31:24:44:41:32:01:58:58 root@SERVERHOSTNAME

there are two methods to add the key to client choose whichever is suited to you.
Method 1:
Then ssh the file to remote server with the name as authorized_keys.
scp -p /root/.ssh/ root@HOSTNAME:/root/.ssh/authorized_keys
Method 2:
Run following command from Server.
# ssh-copy-id -i /root/.ssh/ root@ClientHOst/IP
enter password for client machine.

Validate :
run SSH clientHOST/IP
You should be able to get the terminal of client without asking for any password.

No comments:

Post a Comment