Copy ssh key onto another machine so I can use GitHub there?

Solution 1:

the id_rsa.pub can be copied anywhere without any real danger to it. This is your public key, and is meant for things like this. It is one half of a keypair, and sharing it with places you want access to is how you allow the private key to function.

To allow for remote login, your public key needs to be listed in authorized_keys (authorized_keys2 on some systems). One key on each line, in this format:

ssh-rsa AAAIHAVEREMOVEDTHEMAJORITYOFTHEKEYBECAUSEISEENONEEDTOPOSTTHATWALLOFTEXTHERE9yfRjxw== jarmund@jarmint

To achieve this, once you've copied it over, just append it to the authorized_keys file like this: cat id_rsa.pub >> ~/.ssh/authorized_keys

Most sane systems will cowardly refuse to allow you to use key-based login if the .ssh folder has permissions that are too loose. The folder should be 700, so if you're still having problems: chmod 700 ~/.ssh

In addition, files in the .ssh folder should be 600: chmod 600 ~/.ssh


Edit 1:

The file itself, id_rsa.pub is not required itself on the remote server. Only the contents, as part of authorized_keys. I recommend running ssh -vT [email protected] to enable verbose logging, so that you can see exactly what permissions it complains about.

Edit 2:

This means that none of the keys offered matched what the remote server has on file. What you want to be seeing is something like this:

debug1: Offering RSA public key: /home/jarmund/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 535

Things to check:

  • Ensure that one of the private keys is the one that matches the public key that you added to the remote authorized_keys
  • Ensure that the key matches the username you're trying to log in with (should be the last part of the public key)
  • Try rename authorized_keys to authorized_keys2

Solution 2:

debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/richard/.ssh/id_rsa
debug1: Trying private key: /home/richard/.ssh/id_dsa
debug1: Trying private key: /home/richard/.ssh/id_ecdsa
debug1: No more authentication

According to you debug trace, none of these key files actually exist on the local system, and ssh didn't actually offer any keys to the remote server. Make sure the key you want to use actually exists on the host where you're running ssh, and that the file has the right name. If you want to use a key file other than one of the default files, you have to specify it on the ssh command line:

ssh -i /path/to/some_key -Tv [email protected]

Solution 3:

The server needs your private key to authenticate to Github. Your public key, as its name suggests, is considered public so it can't be enough to authenticate.

If you do not need to use Github on the remote server without having connected through ssh, you should use ssh-agent forwarding. A guide for that is available on Github : https://developer.github.com/guides/using-ssh-agent-forwarding/.

Otherwise, you should generate a new key and link it to your account.