2

What is the best way to enable a command running in screen on a first machine to continue to be able to run commands on a second machine after I am no longer connected to the first?

Here is the background. I have a long running command which needs to regularly collect information from other machines. It does this by sending ssh commands and reading the output. This currently works through ssh agents because I logged in with ForwardAgent.

Currently I can ssh to the first machine, run the command, and it works. Likewise I can start a screen, run the command, disconnect from screen, and it continues running. But if my ssh connection to the first machine breaks, then the ssh agent stops working and the command running in the screen breaks.

I would like the command to be able to run correctly even though I am no longer connected to either machine.

btilly
  • 123
  • 3

2 Answers2

3

AFAIK, that isn't going to be possible. The private keys used by the agent are never transmitted to that intermediate server. If your connection to the intermediate server is lost, there is simply nothing to use for authentication. The agent protocol is design so that your private keys never get transferred away from the system running the agent.

If you are frequently doing work from this Intermediate system, your best option might be to generate a keypair unique to that system, and load it into an agent running on that system when you login and start your process. Obviously, you would also need to publish the associated public key to all the systems you need to access.

Zoredache
  • 130,897
  • 41
  • 276
  • 420
-1

Have you tried looking at "nohup" ?

http://linux.101hacks.com/unix/nohup-command/

It seems like it might be useful to you in this instance.

You can see additional information using $ man nohup

SuperDog
  • 71
  • 1
  • 3
  • 10
  • The problem isn't keeping the software running, the problem is that the running programs lose the ability to authenticate. – Zoredache Dec 09 '16 at 20:03