Copying a new SSH key to a passwordless server
This is a scenario I have ran into a couple of times. I have a server that doesn’t allow logins with a password, and I need to setup a new computer or operating system so it can login.
It’s a simple problem, but I decided to record how I do it in case it helps others. This method requires you to already have pubkey access from another computer.
- Copy the new public key to the computer that already has access
scp ~/.ssh/id_rsa.pub dipper:/tmp
# alternatively scp from dipper
scp mabel:~/.ssh/id_rsa.pub /tmp
- From the computer that has access (
dipper
in this example), copy the ID to the server usingssh-copy-id
ssh-copy-id -fi /tmp/id_rsa.pub grunkel-stan
-f
allows us to only use the public key and -i
specifies the
identity file. That’s it!