Skip to content

Instantly share code, notes, and snippets.

@peacefixation
Last active March 27, 2019 01:39
Show Gist options
  • Save peacefixation/8297a2e8c87b6df719163095db04578d to your computer and use it in GitHub Desktop.
Save peacefixation/8297a2e8c87b6df719163095db04578d to your computer and use it in GitHub Desktop.
Forward SSH agent to remote host
# https://www.ssh.com/ssh/agent
# https://developer.github.com/v3/guides/using-ssh-agent-forwarding/#setting-up-ssh-agent-forwarding
# on the remote host
# /etc/ssh/sshd_config must have 'AllowAgentForwarding yes'
# on your local machine
# /etc/ssh/ssh_config must have 'ForwardAgent yes'
cat >> ~/.ssh/config <<EOF
Host host.example.com
ForwardAgent yes
EOF
ssh-add ~/.ssh/id_rsa
ssh -A user@remote-host
# clone a repo from a server that has your SSH keys that are now forwarded to the remote host
git clone ssh://git@scm-host:7999/project/repo.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment