Labels

Wednesday, August 14, 2013

How to setup a reverse ssh tunnel

Ever wanted to know how you can ssh into your work desktop/server? Well do not worry any longer.....
    • All you need to do is create a reverse tunnel from your Work Desktop/Server to your home server.

    • ssh -nNT -R 5000:local_server:22 username@remote_server
    • Now from the remote_server run this
      ssh -p5000 localhost.... now we are in our work desktop/server.
    • Lets brake this down a bit..

    • The -n option Redirects stdin from /dev/null. This must be used when ssh is run in the background.
    • The -N option does not execute a remote command. This is useful for just forwarding ports.
    • The -T option disables pseudo-tty allocation.
    • The -R option does tha job of setting up the reverse tunnel.
    • Port 5000 is the port that will be listening on the remote_server (this can be any random port over 1024, if you want to run this as a non-root user).
    • local_server is the desktop/server that you are creating the connection from.
    • Port 22 is the port that you are making the ssh connection to.
    • user_name@remote_server is where you are making the ssh connection to for the reverse tunnel.
    • We need to make sure we keep this connection open.
    • In /etc/ssh/sshd_config we need to make sure this is set TCPKeepAlive yes.\


This page was stolen from somewhere else, I can't remember where. Sorry to the original author..

No comments: