How to use Agent Forwarding with sudo

This is apparently a pretty common thing to do but I was unaware. It’s pretty simple once you know about it and I’m just blogging about it to remember:

# SSH into the machine with the -A argument:

  $ ssh -A user@host -p 314

  # Once on the machine if you need to use sudo
  # use the -E argument to save the environment:

  $ sudo -E su

Some concerns are that a clever person on the machine can use your credentials to do nefarious things.

This is useful for allowing you to use your ssh-keys (such as github, or SSHing into other machines using a key) from your local machine on remote machines.

You will need to ensure that your ssh config ~/.ssh/config contains (I put mine at the top) ForwardAgent yes for this to work.

Cheers

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s