0

I am sshing into a remote server. From the remote server, I want to be able to ssh to github.

I don't want to put my private key on the remote server, because other people have access to the machine.

When I try to ssh to github from the remote server, I get the errors shown here: https://stackoverflow.com/questions/24961682/github-permission-denied-message-even-though-key-has-been-added

I have set the following in ~/.ssh/config on my local machine, but it's not helping:

Host remoteHost
    ForwardAgent yes

Can I set up a new keypair on the remote machine and add this to github? Or will this destroy my ability to ssh into the remote machine from my local machine?

migrated from serverfault.com Aug 10 '14 at 19:10

This question came from our site for system and network administrators.

  • what is the output of ssh -v $REMOTE_HOST ssh-add -l 2>&1 | grep agent? – Patrick Aug 10 '14 at 19:17
2

You don't have to copy your ssh key if you don't like, You can forward your local one with -A

 -A      Enables forwarding of the authentication agent connection.  This can also be specified on a per-host basis in a configuration file.

         Agent forwarding should be enabled with caution.  Users with the ability to bypass file permissions on the remote host (for the agent's UNIX-domain socket) can access the local agent through
         the forwarded connection.  An attacker cannot obtain key material from the agent, however they can perform operations on the keys that enable them to authenticate using the identities loaded
         into the agent.

I use it like this,

ssh -At user@server

or sometime even i have to hop thorough another host, so i can run it like this,

ssh -At user@server -- ssh -At user2@server2
  • Right idea, but it's easier to add agent-forwarding to the sshd config. See man(5) sshd_config section AllowAgentForwarding – ericx Aug 5 '14 at 0:31
  • @ericx ssh -A is a client option. AllowAgentForwarding is a server option. – Patrick Aug 10 '14 at 19:13
-1

You can (and should) generate a new ssh key on the remote machine, and add it to github using their instructions:

https://help.github.com/articles/generating-ssh-keys

then copy the newly generated ssh key & add it to github.

Your local key won't be affected.

  • Endlessly creating keys on each of your logins is a bad practice (why? because it becomes too hard to keep track of all of them and redact them as needed). Much better to create keys only on your work stations and configure all your servers to forward the authentication with agent-forwarding. – ericx Aug 5 '14 at 0:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy