Keep Your SSH Identity

So, I’ve been doing a ton of stuff lately on a ton of servers. Almost all of this involves using git to clone repositories into a multitude of servers. The problem with this, is that I’m limited to a single SSH key for all of my git clones. This is tricky, since shelling into a remote box doesn’t give you access to your remote key by default. But you can still keep your SSH identity …

There’s two ways to go about keeping the identity you require through multiple single-level-deep connections. That basically means, you can keep your SSH identity from one box to another. If you hop from one box to another and another, I can’t help you. There’s probably a way to do it. I don’t know it.

Anyways: TWO ways to do this. Both of these options assume you’ve got ssh-agent running on the machine you wish to transfer your identity from. To get this running, do the following:
eval `ssh-agent`

This ensures the ssh-agent daemon is running, to provide an identity when you request it to be forwarded. This also assumes you’ve created a public key to transfer your identity.

So, the ways to do this are:
1. Use the -A flag when you shell into a box.
This basically means whenever you shell into somewhere, you add -A to your ssh command. An example would be:
ssh -A [email protected]

2. Set the ForwardAgent flag to “yes” in your ~/.ssh/config file.
This is a synonym for the -A flag in an ssh command

Both of these options allow you to transfer the key you hold on one machine, to another. Don’t try to use ssh-agent on the machine you connect into though. If you do, you’ll lose your original identity.

So, all together now:

eval `ssh-agent`
ssh -A [email protected]

By ftpcory

I am a fitness, technology, and music enthusiast. I enjoy introspection and reflection. I believe in decentralization of the web and freedom of expression.

Leave a Reply