Windows XP autossh
Jump to navigation
Jump to search
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
- Download Cygwin ( http://www.cygwin.com/ )
- Install Cygwin, selecting the autossh package.
- Start the Cygwin shell (Start -> Programs -> Cygwin).
- Generate a public/private key pair.
- At the command line, run:
ssh-keygen
- Accept the default file locations
- Use an empty passphrase
- Copy your newly-created public key to the SSH server.
scp .ssh/id_rsa.pub user@ssh.host.name:id_rsa.pub
- 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
- 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.
- 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
- 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.
- Test your tunnels.
Get status from windows server
cygrunsrv --query AutoSSH
Remove windows service
cygrunsrv --remove AutoSSH