Linux – Using Same SSH Private Key Across Multiple Machines

githublinuxssh

I've got a Github repo I want to access from two different Linux machines.

For the first machine, I followed Github's instructions for generating SSH keys, and added the resulting public key to Github. This client works fine.

For the second client, I copied the /home/{user}/.ssh/id_rsa file from the first client. I thought this might be all I had to do, but when I try to connect I get 'Permission denied (publickey).'

What am I missing?

Best Answer

The same SSH key should be able to be used from multiple clients. I have different SSH keys for different networks and they're actually stored on an encrypted USB drive that I use from several different computers without a problem.

SSH is very picky about file permissions so I would first check all the permissions from /home/{user} all the way down to the id_rsa file itself.

SSH does not really care for group or world write permissions so make sure you chmod go-w your home directory and the ~/.ssh directory for starters. I'd also make sure they're owned by your user chown ${USER}:${USER}.

For the SSH key itself I chmod 600 them...

If you want I've have additional info on how I manage my SSH keys in my answer to another SSH question.