Prior to my updating to macOS Sierra, autossh
worked just fine. Now, when I run it the ssh session alway terminated immediately. This is the command that I use:
autossh -f -M 8880 -N -y -L 8889:localhost:8888 my-server
When I look at the log-file, I get the following output:
2016/09/29 10:54:17 autossh[15328]: checking for grace period, tries = 0
2016/09/29 10:54:17 autossh[15328]: starting ssh (count 1)
2016/09/29 10:54:17 autossh[15328]: ssh child pid is 15329
2016/09/29 10:54:17 autossh[15328]: check on child 15329
2016/09/29 10:54:17 autossh[15328]: set alarm for 600 secs
2016/09/29 10:54:17 autossh[15329]: execing /usr/bin/ssh
2016/09/29 10:54:21 autossh[15328]: check on child 15329
2016/09/29 10:54:21 autossh[15328]: ssh exited with error status 255; restarting ssh
This goes on and on. However, when I run the same command without the -f
option (not running in the background), everything works fine. This looks like the problem described here, but I'm not using a custom id.
What could be the cause for this, and how to fix it?
Best Answer
Since macOS Sierra,
ssh-add
doesn't automatically load keys added withssh-add -K
on startup. In order for this to work, I had to addssh-add -A
to my.bashrc
, now things work as expected.