Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an ssh script which use ssh key forwarding on a remote system to do thing in even more remote systems.

I have to run the script in a screen session so that I can detach from it. But the authorization that was granted to the remote system by ssh-key-forwarding needs to be present. Atleast until the script has finished.

Any ideas how to go about it?

share|improve this question
up vote 4 down vote accepted

If you disconnect, then the ssh agent socket gets closed. There is no way you can use agent forwarding if ssh closed. The private key is loaded in the agents memory. It is not copied in any way to the systems you have forwarded to. When you disconnect the private key will be unavailable.

Your only option would be to create or copy a keypair onto that system, or stay connected.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.