We have a build system that needs an active ssh connection with mercurial and to do so, it needs an ssh-agent loaded with a key constantly..

The thing is that, even though that after creating the ssh agent eval $(ssh-agent -s) and setting up the environment variables:


Doing env | grep SSH:

SSH_CLIENT=***.***.***.*** 53371 22
SSH_CONNECTION=***.***.***.*** 53371 22

After I log out from them EC2 Instance, after a few hours of the program running and pulling repos, etc. It would suddenly get this error:

CommandError: (-1, 'remote: ssh_exchange_identification: Connection closed by remote host', 'abort: no suitable response from remote hg!')

Then when I go and check the env | grep SSH the only thing that is setup is the SSH_CONNECTION and the SSH_CLIENT.

  1. Why would this occur? Are these environment variables only setup in the session?

  2. And if so, why would it only fail after long hours of already logging out?

  3. How can I make so that these environment variable are always there so that it doesn't break my program by not having these 2 environment variables setup?

  • Are you running your session in screen or tmux on the remote host?
    – Kusalananda
    Jun 28, 2019 at 16:46
  • I am not running either screen or tmux Jun 28, 2019 at 16:47

1 Answer 1


Time out in your password but I do not know your operating system or the settings.

You must log in to answer this question.

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