I want to run a bash script (as root) that among other things establishes reverse SSH tunnel using
autossh. The SSH key has a passphrase.
Ideally I would like to have to login as root in terminal and the passphrase would be retrieved from a keyring (the computer has Gnome), or something like this, and supplied to
autossh(if needs be I can set SSH passphrase and the root password to be the same).
If #1 is absolutely impossible I can do two things - (a) login and (b) run
ssh-agent /bin/bashand then provide the passphrase
However even manual input of the passphrase as mentioned in #2 doesn't work.
If I run
ssh-agent/ssh-add (as mentioned above), SSH itself works:
ssh -f -N -T -R 8888:localhost:22 -p 9999 email@example.com
autossh -M 7777 -f -N -T -R 8888:localhost:22 -p 9999 firstname.lastname@example.org
How can I troubleshoot #2 and then ideally implement also #1?