Server A needs to connect over svn+ssh to Server B to grab some source files for deploying on Server A. My deployment script runs from my local dev machine via:

ssh serverA 'bash -s' < deploy.sh 

I have a passphraseless public/private key pair set up between Server A and Server B. When I log in a local session to Server A, I have keychain setup and svn+ssh connections to Server B aren't a problem. The deploy.sh script runs successfully on Server A from a local session. However when SSHing into it from my dev box the same script will not run remotely.

What way do I call ssh-agent from my deploy script to get Server B to accept connections from it when I run the commands remotely on Server A?


2 Answers 2


Try using -A option in order to forward auth agent connection, something like this:

ssh -A serverA 'bash -s' < deploy.sh

Or, even better, either add it to your ~/.ssh/config so that it will affect all connections initiated by your user, or use it per-host, or add it to the systemwide ssh client config. That way all applications using ssh will benefit, and you have to maintain configuration only in one place.

See also the excerpt from the ssh man-page:

 -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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .