I solved it, but I am still not exactly sure of the original source of the problem. I deleted the .ssh directories in my user account on the relay server, work, and home. From both home and work, I generated new keys using the command as non-root user:
Code:
ssh-keygen -t rsa -b 4096
I then logged into the relay server using a password, and created a file at ~/.ssh/authorized_keys on the relay server. On both home and work computers, I opened the file ~/.ssh/id_rsa.pub in gedit and copied the contents to ~/.ssh/authorized_keys on the remote relay server. I then made sure that I could log in to the relay server from both home and work without a password. Then I issued the autossh command from my home computer to set up remote port forwarding:
Code:
autossh -M 20000 -N -R 10000:localhost:10000 matt@relayserver.com &
From work, I can now log into my home computer using the command:
Code:
ssh matt@relayserver.com -p 10000
I have a script that does incremental backups nightly from my work computer to my home computer using ssh and rsync. I made a test run of the script from a terminal at work and it works as expected.
If anyone else reads this thread for similar problems with ssh keys, there are two issues that I should point out. First, the autossh command:
Code:
autossh -M 20000 -N -R 10000:localhost:10000 matt@relayserver.com &
will give no indication in the terminal that it failed to establish a connection. If ssh requires a password, the above autossh command will not prompt you for one, it will just return the terminal prompt. The other issue is that an old autossh process may be running in the background and it won't die. That is the point of autossh I guess. You can find the pid of autossh with the command:
If you try to kill the process with:
where <pid> is the pid of the autossh process, it won't die. To kill autossh, you have to issue the SIGKILL signal:
The above command does kill autossh, then you can reestablish a new connection with autossh.