There have been many situations that I would like to have remote access to a Linux server, but I don’t have administration rights to the network the server resides on.
A few situations I’ve run in to:
1. A friend has a server and wants you to take a quick look (but no ports forwarded)
2. Customer has a server that you need to look at, but no remote access
3. You are working locally on a server but need to leave and access it later from another location
1. You need to have a publicly accessible Linux server with an SSH account (please don’t use root for this!)
2. Add a dumb user that has shell access but nothing else, don’t run any applications as this user (used for SSH only)
So in the case where you are physically at the server and need to get to it later, type:
ssh -N -f -R 19999:localhost:22 firstname.lastname@example.org
The options make it so after you authenticate with the password the shell goes to the background.
188.8.131.52 needs to be replaced with your IP/Domain of the server you control
sshuser needs to be replaced with the dumb SSH user you setup earlier
Now when you get home, ssh to your 184.108.40.206 server. Then use the Remote forwarding to get back to the original server:
ssh -p19999 email@example.com
You should now be on your remote server.
If you want to kill the connection, on your public server type:
ps -ef | grep ssh
Then you can:
Remember when I said that you must create a dumb user earlier? This is in case you are in the situation where you must give the command to someone over email and have them execute it for you. That way you aren’t handing over root-level access to your server…ever.