Skip to content

Instantly share code, notes, and snippets.

@atl
Last active February 15, 2019 16:57
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atl/4525323 to your computer and use it in GitHub Desktop.
Save atl/4525323 to your computer and use it in GitHub Desktop.
enable ssh-agent transparently and pervasively in Mac OS X Lion/Mountain Lion

This is a quick configuration upgrade that allows you to continue using ssh as you have, but with the added benefit of ssh-agent forwarding when logged into remote hosts, meaning no more keys on intermediate servers and the like.

Requirements

This snippet assumes that you've been using ssh, ssh keys, and authorized_keys on remote hosts.

  • .ssh/id_dsa and/or .ssh/id_rsa already exist
  • keys are authorized on the remote servers you have been using
  • you have at least a minimal working .ssh/config file
# persistently add default keys to Keychain
ssh-add -K
# prepend ForwardAgent to existing ssh_config, meaning `ssh -A` is the effective default
echo "ForwardAgent yes" | cat - ~/.ssh/config > /tmp/out && mv /tmp/out ~/.ssh/config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment