I’d wager many of you know this already. Having done this a couple times the last two days though, I thought I’d add it for those that don’t. Maybe it’s useful to someone.
Problem: You want to log into a remote server with SSH and you don’t want to type a password. You know about key pairs and authorized_keys and are ready to copy your public key. You might be tempted to do it like this:
- SCP your identity to the remote machine (have to type your password again).
- ssh to the remote server (have to type your password again)
- append the public id to the authorized keys file
- delete the copied file
- try the keyless login
Here is where you can save a few steps. You can append the file with ssh instead of copying the file over with scp. This saves you a login and typing your password once.
cat id_dsa.pub | ssh remote_server "cat >> [path to user home]/.ssh/authorized_keys"
There. Type your password once for the copy and then test the passwordless login.