Sometimes it is necessary to create a tunnel in order to access a port on a remote box from your local box and there is a firewall preventing you from reaching it. As long as you have access to SSH, you can access this port. In order to do so, just use the following command:
ssh -N user@remote-server -L localport/localhost/remoteport
The -N switch is used so commands are not executed on the remote system. Now, if you are having issues keeping the tunnel open due to lack of traffic, you can change the line to the following:
ssh -N user@remote-server -o ServerAliveInterval=15 -L localport/localhost/remoteport
This will then generate a heartbeat every 15 seconds so the tunnel will remain up.
This blog contains posts of information that have helped us with some tasks. We have posted them to help remind us of how to do them. Maybe it will also help somebody else, as well.
Showing posts with label ssh. Show all posts
Showing posts with label ssh. Show all posts
Tuesday, November 8, 2011
Wednesday, November 2, 2011
Keep an SSH Connection Open Through Even During Dormant Times
If you manage any Linux servers over the internet through ssh, you may have experienced your client disconnecting after times of inactivity. I know I do and it annoys me to death. There is a parameter you can add to the ssh connection in order to keep it up over these type of connections. Just do the following:
ssh -o ServerAliveInterval=15 login@servername
The parameter -o ServerAliveInterval=15 adds the functionality of sending a heartbeat type message to the server every 15 seconds if data has not been sent in the last 15 seconds. This parameter is customizable.
ssh -o ServerAliveInterval=15 login@servername
The parameter -o ServerAliveInterval=15 adds the functionality of sending a heartbeat type message to the server every 15 seconds if data has not been sent in the last 15 seconds. This parameter is customizable.
Subscribe to:
Posts (Atom)