So recently I found that team viewer was available for raspberry pi.
So to make connecting to my Pi which lives behind a firewall easier I installed it.
It was brilliant until I wanted to move files. Then my team viewer id changed and I could not get back into it.
Since I needed to do both of those things I found a way to do them.
How ssh to a Pi behind a firewall
Note: This requires an intermediate server like a Digital Ocean droplet you can ssh into.
On the Raspberry Pi
First you will need to get the Pi to bind its ports to the intermediate server.
I put the following in the crontab for Pi as it means it will reconnect on reboot.
@reboot autossh -f -NR 12345:localhost:22 user@remote-server-ip
The -f means autossh will run as a background process which means root won’t kill it.
-N means that ssh will not execute a remote command.
-P is what binds the ports.
On local computer to connect to the Pi
Run the following to bind ports to the remote server:
ssh user@remote-server-ip -L 23456:localhost:12345
Then in another terminal run the following to ssh into the Pi
ssh -p 23456 pi@localhost
Find out team viewer id on the Pi
teamviewer --info print version, status, id
To mount the Pi to your local file system
sshfs -p 23456 pi@localhost:/ /path/to/mount/point
How do I login if the password keeps changing
In the settings for team viewer on the raspberry pi there is an option to set a master password which will always work.