- Suppose the domain name of your server is server, and your login name loginname.
- On the client, generate a public and private key.
ssh-keygen -C loginname@server -t dsa
When asked for a password, simply press return. The private key is stored in ~/.ssh/id_dsa, and the public key in ~/.ssh/id_dsa.pub. Never give the private key away!
- Copy the public file to the server with
scp ~/.ssh/id_dsa.pub loginname@server:~/
- Login on the server with
ssh loginname@server
append the copied file to ~/.ssh/authorized_keys with
cat ~/id_dsa.pub >>~/.ssh/authorized_keys
- If you want to enable this features on other servers, just repeat step 3 on each of the servers.
That’s it! If you have done everything correctly, the next time you login via SSH or use CVS over SSH, you will not need to enter a password yet you have a secure connenction.
In case this does not work check /var/log/auth.log or /var/log/secure for error on server machine. If you see
Authentication refused: bad ownership or modes for directory /home/dave/.ssh
This is bcoz of bad permission these can be fixed with below commands.chmod g-w /home/your_user chmod 700 /home/your_user/.ssh chmod 600 /home/your_user/.ssh/authorized_keys
Monday, May 14, 2012
Secure SSH, CVS, SCP without Password Prompt
Subscribe to:
Posts (Atom)