add ssh to aditional computers

Posted October 26, 2019 2.3k views

I went through setting up ssh with keys, and everything works with keys and passphrase.

How do I make it work on another client computer. Do I just copy some files or generate another keys on the to other laptop computers I have?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
3 answers

Are you trying to set up SSH access from another computer to your Droplet, or are you trying to use the SSH key you created to access a different Droplet or server?

Setup ssh from another computer to access same droplet.

I figured out if I copied files from .ssh from old client to new client computer the login with keys works. I was wondering if a server/droplet can be accesed by more than one key pair. I asumed if so the server would have to have 2 entries in authorized_keys, but I don’t know if this is possible or how to add a second one.

I didn’t really want the same key pairs on two client computers. I want to authorize more than one key pair to ssh to droplet, incase I lose or have my laptop stolen.

  • Yes, you can put many keys in the authorized_keys file, all you need is the public key from whatever host (or private/public key pair) to which you want to grant access. If you’re connecting from a Linux system, then you can find it like this:

    $ less ~/.ssh/

    That’s the default location of the ssh public key for the user account to which you logged in. Copy the contents of that file, then add that as a new line in the authorized_keys file on your droplet.

    On other OSes (including mobile OSes by the way) the public key will be in a different place, or you may not even be able to access it directly. Check the documentation for the SSH client you’re using for how to locate the public key for those systems.

Hello, @stevehendo34

You can use the same steps in order to add the client’s public key in the authorized_keys file on the server. As already mentioned this file can store multiple keys.

You can add the keys using the following command:

cat ~/.ssh/ | ssh demo@ "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >>  ~/.ssh/authorized_keys"

This can be executed from the client’s machine using their user (chaging the demo in the example with their respective user)

You can also check the whole tutorial we have for the ssh keys–2

Hope this helps!