Windows XP autossh: Difference between revisions

From Skytech
Jump to navigation Jump to search
Line 35: Line 35:


4. Generate a public/private key pair.
4. Generate a public/private key pair.
1. At the command line, run:
- At the command line, run:
2. <pre>ssh-keygen</pre>
- <pre>ssh-keygen</pre>
3. Accept the default file locations
- Accept the default file locations
4. Use an empty passphrase
- 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. <pre>scp .ssh/id_rsa.pub user@ssh.host.name:id_rsa.pub</pre>
- <pre>scp .ssh/id_rsa.pub user@ssh.host.name:id_rsa.pub</pre>


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.
- Login to your SSH server.
2. <pre>mkdir .ssh</pre>
- <pre>mkdir .ssh</pre>
3. <pre>cat id_rsa.pub >> .ssh/authorized_keys</pre>
- <pre>cat id_rsa.pub >> .ssh/authorized_keys</pre>


7. Test your key.
7. Test your key.
1. Logout of your SSH sever.
- 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.
- 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.
- Logout of your SSH server.
4. Exit of the Cygwin shell.
- 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).
- Now back in Windows, open a new command Window (Start -> Run -> cmd).
2. <pre>cd C:\cygwin\bin</pre>
- <pre>cd C:\cygwin\bin</pre>
3. <pre>cygrunsrv -I AutoSSH -p /usr/bin/autossh -a "-M 20000 -L localaddress:port:serveraddress:port user@ssh.host.name" -e AUTOSSH_NTSERVICE=yes</pre>
- <pre>cygrunsrv -I AutoSSH -p /usr/bin/autossh -a "-M 20000 -L localaddress:port:serveraddress:port user@ssh.host.name" -e AUTOSSH_NTSERVICE=yes</pre>


9. Tweak Windows service settings.
9. Tweak Windows service settings.
1. Open the Services management console (Administrative Tools -> Services).
- Open the Services management console (Administrative Tools -> Services).
2. Edit the properties of the AutoSSH service.
- 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.
- 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.
- Start the service.


10. Test your tunnels.
10. Test your tunnels.

Revision as of 21:25, 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

Matts ten things to do

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.

  - At the command line, run: 

-

ssh-keygen
  - Accept the default file locations
  - Use an empty passphrase

5. Copy your newly-created public key to the SSH server.

-

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.

  - Login to your SSH server.

-

mkdir .ssh

-

cat id_rsa.pub >> .ssh/authorized_keys

7. Test your key.

  - Logout of your SSH sever.
  - 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.
  - Logout of your SSH server.
  - Exit of the Cygwin shell.

8. Install autossh as a Windows service.

  - Now back in Windows, open a new command Window (Start -> Run -> cmd).

-

cd C:\cygwin\bin

-

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.

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

10. Test your tunnels.