Monday, February 7, 2011

Cygwin: Making a ssh connection with tunnels to your server

To make a ssh connection to a linux server, do the following:
Start by loading Cygwin: Start a cmd prompt and load Cygwin:
C:\folder>loadcygwin (the script is described here).

the run the ssh connect command:
C:\folder>ssh user@server.com

This will prompt for your password before allowing the connecntion. Voilá!

If you want to take advantage of one of the strengths of ssh, namely the tunnels run the command as:
C:\folder>ssh user@server.com -L 123:remotehost:456

which will open port 123 locally (on your computer/localhost) which is tunneled to port 456 on the server remotehost.

You can with benefit put this command into a batch (.cmd) file, such as the following ssh_server_com.cmd.

ssh_server_com.cmd:

@echo off
echo Connecting ...
call loadcygwin.cmd

ssh user@server.com -L1125:localhost:25 
-L22993:imap.gmail.com:993
-L993:imap.gmail.com:993 
-L22995:pop.gmail.com:995 
-L22587:smtp.gmail.com:587
-L8888:localhost:8888 
-L8080:localhost:8080

No comments:

Post a Comment