Linux and FreeBSD fun. > SSH stuff

SSH stuff

ssh -L 2222: firewall.example.com
Makes a tunnel from localhost:2222 trough firewall.example.com to internal address

URL in  your browser will be :

To make a tunnel for ssh to without the extra open terminal.

ssh -f -L 2222: firewall.example.com sleep 200
Then open a ssh connection to localhost:2222 and forget about the first one

ssh localhost -p 2222

The -f switch send the process in the background for 200 seconds because of the 'sleep 200'.
If you make the new connection within 200 seconds you're on.
When you close your session with localhost:2222 after the 200 seconds, your first ssh session will die nice and clean.

If you want to make a tunnel back to yourself from a host you connect to then :

ssh -f -R 2222:localhost:80 remote sleep 200

You can then connect to remote host at port 2222 and
get port 80 at the localhost within the 200 seconds.

SCP (Secure Copy)
You can copy a file with the scp command.

Copy from you to server.com:

scp <filename> user@server.com:/home/user/<filename>

Or if your SSH server uses a non standard port.

scp -o Port=2222 <filename> user@server.com:/home/user/<filename>

Copy from server.com to you:

scp -o Port=2222 user@server.com:<filename> /home/user/<filename>

Note !
You do not need to define a destination filename if you want to preserve the original name.


SFTP (Secure FTP)
If you want to make a sftp session to localhost port 2222, then :
sftp -o port=2222 localhost

Some usefull link(s) :

Getting started with SSH
Creating virtual private networks with tsocks and VTun