How to generate SSH keys and implement for key authentication.
login to local machine with user you will be using for connect to remote.
1. generate keys:
ssh-keygen -t dsa
2. copy id_dsa.pub to remote machine to /tmp directory
scp ~/.ssh/id_dsa.pub remote_machine:/tmp
3. login to remote machine and append new key to authorized_keys2 file in home folder
cat /tmp/id_dsa.pub >> ~/.ssh/authorized_keys2
4. log out and that it is.
You can try with:
ssh remoteuser@remoteserver
and you will be connected to remote server without password.
Hi Franz,
When I want to do step 2 on the remote server
scp ~/.ssh/id_dsa.pub remote_machine:/tmp
I get this error:
“bash: /.ssh/authorized_keys2: No such file or directory”.
What should I do?
@Rudolf,
Not sure if you still need this, but try this.
1st see if the .ssh directory exist with: ls -la ~
If it does not exist, you will need to create it with the following command: mkdir ~/.ssh
Now you will need to chmod it to 700. Use the following command: chmod 700 ~/.ssh
Now run the following to append the id_dsa.pub to authorized_keys2. Do this with the following command: cat /tmp/id_dsa.pub >> ~/.ssh/authorized_keys2