Windows XP autossh: Difference between revisions

From Skytech
Jump to navigation Jump to search
(Created page with "Category:Linux = Windows XP and Autossh = First off, one needs cygwin. Download from here: <pre> http://www.cygwin.com/ </pre> Select setup and be sure to select '''Autos...")
 
 
(15 intermediate revisions by the same user not shown)
Line 12: Line 12:


All required dependencies will be automatically installed as well.
All required dependencies will be automatically installed as well.

= 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:
<pre>ssh-keygen</pre>
** Accept the default file locations
** Use an empty passphrase

* Copy your newly-created public key to the SSH server.
<pre>scp .ssh/id_rsa.pub user@ssh.host.name:id_rsa.pub</pre>

* Add your public key to your list of authorized keys on the server.
** Login to your SSH server.
<pre>mkdir .ssh</pre>
<pre>cat id_rsa.pub >> .ssh/authorized_keys</pre>

* 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).
<pre>cd C:\cygwin\bin</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>
*** I had to alter the above slightly to get it to work on my end; just putting my version here as well (passing rdp to internal port 51353)
<pre>cygrunsrv -I AutoSSH -f "Autossh tunnel" -t auto -y tcpip -O -u $USER -w $PASS -p /usr/bin/autossh -a "-M 20507 -R 51353:127.0.0.1:3389 $USER@$SERVER -p 15266 -g2CN" -e AUTOSSH_NTSERVICE=yes</pre>


* 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 =
<pre>
cygrunsrv --query AutoSSH
</pre>

= Remove windows service =
<pre>
cygrunsrv --remove AutoSSH
</pre>

Latest revision as of 21:33, 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.

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

  • 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
      • I had to alter the above slightly to get it to work on my end; just putting my version here as well (passing rdp to internal port 51353)
cygrunsrv -I AutoSSH -f "Autossh tunnel" -t auto -y tcpip -O -u $USER -w $PASS -p /usr/bin/autossh -a "-M 20507 -R 51353:127.0.0.1:3389 $USER@$SERVER -p 15266 -g2CN" -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