I have set up a tunnel via autossh.
This works:
autossh -M 33201 -N -i myIdFile -R 33101:localhost:22 autossh@myhost.com
I would like to run autossh in background. Seems easy using the -f
option.
This does not work, however:
autossh -f -M 33201 -N -i myIdFile -R 33101:localhost:22 autossh@myhost.com
Autossh runs in the background fine, but the ssh connection seems to fail every time. In /var/syslog I see multiple occurences of:
autossh[3420]: ssh exited with error status 255; restarting ssh
What am I doing wrong? A wild guess is it has something to do with the authentication via key file. How can I debug this (adding -v to the ssh options does not seem to log anywhere).
Edit: I got some ssh logs using the -y option
/usr/bin/ssh[3484]: debug1: Next authentication method: publickey
/usr/bin/ssh[3484]: debug1: Trying private key: /home/myuser/.ssh/id_rsa
/usr/bin/ssh[3484]: debug1: Trying private key: /home/myuser/.ssh/id_dsa
/usr/bin/ssh[3484]: debug1: Trying private key: /home/myuser/.ssh/id_ecdsa
/usr/bin/ssh[3484]: debug1: No more authentication methods to try.
/usr/bin/ssh[3484]: fatal: Permission denied (publickey).
autossh[3469]: ssh exited with error status 255; restarting ssh
So it seems autossh does not accept my identiy file (-i myIdFile
) when using the -f option. Why is that?
(autossh 1.4c on Raspian)