Agent Forwarding in Mac and Linux Systems
First, start your
ssh-agentwith the command below.
$ eval $(ssh-agent)
You should see an output similar to this:
Agent pid 48792
Next, add your ssh private keys to the running agent (using the
ssh-addcommand on line 1). This step may be repeated for every key pair you use to connect to different git servers. For most, this file is called
id_rsaand will live in
~/.ssh/id_rsa. If you set a password for your ssh keys, the agent will prompt you to enter them.
$ ssh-add ~/.ssh/id_rsa
Enter passphrase for ~/.ssh/id_rsa:
Identity added: ~/.ssh/id_rsa
Confirm the ssh keys have been loaded into the agent with
Now ssh into Oscar with the
-Aoption as shown on the first line below (replace
usernamewith your Oscar username).
-Awill forward your ssh-agent to Oscar, enabling you to use the ssh keys on your laptop while logged into Oscar.
If you have ssh keys setup on your local computer to connect to GitHub, you can confirm your ssh-agent was properly forwarded by checking GitHub . If the ssh command fails, your agent has not been properly forwarded.
$ ssh [email protected]
Hi JaneDoe! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
To make these changes permanent, you can add the
ForwardAgent yesoption to your ssh configuration file. To learn more about configuring your ssh connections, visit