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.