Ssh: automatic login (en)
Jump to navigation
Jump to search
Source: http://wp.uberdose.com/2006/10/16/ssh-automatic-login/
- public ssh key, check if the file id_dsa.pub exists
~/.ssh
- if id_dsa.pub does not exist in ~/.ssh, execute
chmod 700 ~/.ssh ssh-keygen -t dsa ssh-keygen -t rsa
- copy to the remote server
scp ~/.ssh/id_dsa.pub remoteuser@remoteserver.com: scp ~/.ssh/id_rsa.pub remoteuser@remoteserver.com:
- on the remote server, append the content of the public key id_dsa.pub to ~/.ssh/authorized_keys and delete the file id_dsa.pub
mkdir .ssh touch .ssh/authorized_keys cat id_dsa.pub >> .ssh/authorized_keys cat id_rsa.pub >> .ssh/authorized_keys
Or simultaneously perform with the method
ssh -l remoteuser remoteserver.com 'mkdir .ssh' ssh -l remoteuser remoteserver.com 'touch ~/.ssh/authorized_keys' cat ~/.ssh/id_dsa.pub | ssh -l remoteuser remoteserver.com 'cat >> ~/.ssh/authorized_keys'
do not forget to delete id_dsa.pub from the home directory on the remote server
afterward, we can log in without being asked for a password
ssh -l remoteuser remoteserver.com ssh remoteuser@remoteserver.com
Other Alternatives
The whole process is much easier if you just use:
ssh-copy-id [-i [identity_file]] [user@]machine
ssh-keygen -t dsa ssh-keygen -t rsa ssh-copy-id user@machine