How to add RSA key to authorized_keys file?
Solution 1:
Make sure when executing Michael Krelin's solution you do the following
cat <your_public_key_file> >> ~/.ssh/authorized_keys
Note that without the double >>
the existing contents of authorized_keys
will be over-written (nuked!) and that may not be desirable.
Solution 2:
mkdir -p ~/.ssh/
To overwrite authorized_keys
cat your_key > ~/.ssh/authorized_keys
To append to the end of authorized_keys
cat your_key >> ~/.ssh/authorized_keys
Solution 3:
There is already a command in the ssh suite to do this automatically for you. I.e log into a remote host and add the public key to that computers authorized_keys file.
ssh-copy-id -i /path/to/key/file [email protected]
If the key you are installing is ~/.ssh/id_rsa
then you can even drop the -i
flag completely.
Much better than manually doing it!