Jay Taylor's notes

back to listing index

Creating persistent SSH tunnels in Windows using autossh | boltblog

[web search]
Original source (blog.dhampir.no)
Tags: SSH windows windows-7 autossh blog.dhampir.no
Clipped on: 2015-05-07

old-school tech and modern annoyances
  1. 1Download Cygwin (http://www.cygwin.com/)
  2. 2Install Cygwin, selecting the autossh package.
  3. 3Start the Cygwin shell (Start → Programs → Cygwin).
  4. 4Generate a public/private key pair.
    1. 0At the command line, run: ssh-keygen
    2. 0Accept the default file locations
    3. 0Use an empty passphrase
  5. 1Copy your newly-created public key to the SSH server.
    1. 0scp .ssh/id_rsa.pub user@ssh.host.name:id_rsa.pub
  6. 1Add your public key to your list of authorized keys on the server.
    1. 0Login to your SSH server.
    2. 0mkdir .ssh
    3. 0cat id_rsa.pub >> .ssh/authorized_keys
  7. 1Test your key.
    1. 0Logout of your SSH sever.
    2. 0Login 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. 0Logout of your SSH server.
    4. 0Exit of the Cygwin shell.
  8. 1Install autossh as a Windows service.
    1. 0Now back in Windows, open a new command Window (Start → Run → cmd).
    2. 0cd C:\cygwin\bin
    3. 0cygrunsrv -I AutoSSH -p /usr/bin/autossh -a “-M 20000 -L localaddress:port:serveraddress:port user@ssh.host.name” -e AUTOSSH_NTSERVICE=yes
  9. 1Tweak Windows service settings.
    1. 0Open the Services management console (Administrative Tools → Services).
    2. 0Edit the properties of the AutoSSH service.
    3. 0In the “Log On” tab, select the “This account” radio button and set the service to run as your current user.
    4. 0Start the service.
  10. 1Test your tunnels.
  11. 2Consider making a scheduled task to start the service every hour or so, in case autossh goes boom.
Categories: Howto's, Windows | Comments

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *

Email *

Website

Comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

 
Microsoft (R) Windows 98
   (C)Copyright Microsoft Corp 1981-1998.
 
C:\>
_