Windows XP autossh: Difference between revisions

From Skytech
Jump to navigation Jump to search
No edit summary
Line 28: Line 28:


1. Download Cygwin (http://www.cygwin.com/)
1. Download Cygwin (http://www.cygwin.com/)

2. Install Cygwin, selecting the autossh package.
2. Install Cygwin, selecting the autossh package.

3. Start the Cygwin shell (Start -> Programs -> Cygwin).
3. Start the Cygwin shell (Start -> Programs -> Cygwin).

4. Generate a public/private key pair.
4. Generate a public/private key pair.
1. At the command line, run: ssh-keygen
1. At the command line, run: ssh-keygen
2. Accept the default file locations
2. Accept the default file locations
3. Use an empty passphrase
3. Use an empty passphrase

5. Copy your newly-created public key to the SSH server.
5. Copy your newly-created public key to the SSH server.
1. scp .ssh/id_rsa.pub user@ssh.host.name:id_rsa.pub
1. scp .ssh/id_rsa.pub user@ssh.host.name:id_rsa.pub

6. Add your public key to your list of authorized keys on the server.
6. Add your public key to your list of authorized keys on the server.
1. Login to your SSH server.
1. Login to your SSH server.
2. mkdir .ssh
2. mkdir .ssh
3. cat id_rsa.pub >> .ssh/authorized_keys
3. cat id_rsa.pub >> .ssh/authorized_keys

7. Test your key.
7. Test your key.
1. Logout of your SSH sever.
1. Logout of your SSH sever.
Line 45: Line 51:
3. Logout of your SSH server.
3. Logout of your SSH server.
4. Exit of the Cygwin shell.
4. Exit of the Cygwin shell.

8. Install autossh as a Windows service.
8. Install autossh as a Windows service.
1 .Now back in Windows, open a new command Window (Start -> Run -> cmd).
1 .Now back in Windows, open a new command Window (Start -> Run -> cmd).
2. cd C:\cygwin\bin
2. cd C:\cygwin\bin
3. cygrunsrv -I AutoSSH -p /usr/bin/autossh -a "-M 20000 -L localaddress:port:serveraddress:port user@ssh.host.name" -e AUTOSSH_NTSERVICE=yes
3. cygrunsrv -I AutoSSH -p /usr/bin/autossh -a "-M 20000 -L localaddress:port:serveraddress:port user@ssh.host.name" -e AUTOSSH_NTSERVICE=yes

9. Tweak Windows service settings.
9. Tweak Windows service settings.
1. Open the Services management console (Administrative Tools -> Services).
1. Open the Services management console (Administrative Tools -> Services).
Line 54: Line 62:
3. In the "Log On" tab, select the "This account" radio button and set the service to run as your current user.
3. In the "Log On" tab, select the "This account" radio button and set the service to run as your current user.
4. Start the service.
4. Start the service.

10. Test your tunnels.
10. Test your tunnels.
</pre>
</pre>

Revision as of 21:17, 12 June 2011


Windows XP and Autossh

First off, one needs cygwin. Download from here:

http://www.cygwin.com/

Select setup and be sure to select Autossh from the Net list.

All required dependencies will be automatically installed as well.

Connection string (cygwin)

cygrunsrv -I AutoSSH -f "Autossh tunnel" -t auto -y tcpip -O -u $USER -w $PASS -p /usr/bin/autossh -a "-M 20007 -R 12003:127.0.0.1:3389 $USER@$SERVER -p 15266 -g2CN" -e AUTOSSH_NTSERVICE=yes


Update

Follow this howto and adjust line from there to have the extra triggers from above if you want to skip those steps. http://www.matthanger.net/2008/04/creating-persistent-ssh-tunnels-in.html

I've copied and listed the above here below for easier reference - all credit goes to Matt

Creating persistent SSH tunnels in Windows using autossh

1. Download Cygwin (http://www.cygwin.com/)

2. Install Cygwin, selecting the autossh package.

3. Start the Cygwin shell (Start -> Programs -> Cygwin).

4. Generate a public/private key pair.
   1. At the command line, run: ssh-keygen
   2. Accept the default file locations
   3. Use an empty passphrase

5. Copy your newly-created public key to the SSH server.
   1. scp .ssh/id_rsa.pub user@ssh.host.name:id_rsa.pub

6. Add your public key to your list of authorized keys on the server.
  1. Login to your SSH server.
  2. mkdir .ssh
  3. cat id_rsa.pub >> .ssh/authorized_keys

7. Test your key.
  1. Logout of your SSH sever.
  2. Login to your SSH server again. This time, your key will be used for authentication and you won't be challenged for your login credentials. If you are not logged in automatically, review the previous steps. Or   contact your server administrator.
  3. Logout of your SSH server.
  4. Exit of the Cygwin shell.

8. Install autossh as a Windows service.
  1 .Now back in Windows, open a new command Window (Start -> Run -> cmd).
  2. cd C:\cygwin\bin
  3. cygrunsrv -I AutoSSH -p /usr/bin/autossh -a "-M 20000 -L localaddress:port:serveraddress:port user@ssh.host.name" -e AUTOSSH_NTSERVICE=yes

9. Tweak Windows service settings.
  1. Open the Services management console (Administrative Tools -> Services).
  2. Edit the properties of the AutoSSH service.
  3. In the "Log On" tab, select the "This account" radio button and set the service to run as your current user.
  4. Start the service.

10. Test your tunnels.