Social security for getting on a large amount Beat The Cycle Of Debt Beat The Cycle Of Debt for an approved in addition questions.

Remote Access to Linux without forwarding ports

Posted: January 10th, 2010 | Author: | Filed under: Linux, Tech | Tags: , , , , , , | 2 Comments »

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 sshuser@

The options make it so after you authenticate with the password the shell goes to the background. 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 server. Then use the Remote forwarding to get back to the original server:
ssh -p19999 sshuser@
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:
kill -9

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.