SSH Tunnel / putty / plink

Good Morning,

I have a SSH tunnel configured,  i am trying to turn it into a windows service but having issues.

on windows 2k8 using puttyy / plink

sc create ssh_tunnel binPath= "C:\SSH\plink.exe \"SSH Tunnel to Ubuntu\"" DisplayName= "SSH_Tunnel" start= auto

Service is created but fails to start - Error 1053 the service did not respond in a timely fashion...

i cant seem to get it to start ? - any ideas?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Spikeuk30Author Commented:
when i try

sc create ssh_tunnel binPath= C:\SSH\plink.exe DisplayName= "SSH_Tunnel" start= auto

the service is created but when try to start  'error2 the system cannot find the file specified?'
Daniel HelgenbergerCommented:
Where are the command line parameters for the plink-connection? These have to be specified with bin path. Another way is to edit the registry value of the service to add the command line parameters.

It may be you cannot just use a random binary for a windows service - it needs to be daemonizable. But there a several utilities which do this job for you:

Option 1: The recommended way is to use SRVANY.exe from Windows Resource Kit:

Option 2: Use pagent.exe from putty download page - this can be used in conjunction with SC and plink, though in plink -noagent needs to be specified then:
plink -noagent

Open in new window

Option 3, the easiest: I once used AlwaysUp - this is a GUI witch creates a Windows Service, this runs then plink for you:

Follow this guide:
Spikeuk30Author Commented:
For testing purposes I tried Plink.exe without any params to see if it would run the exe as a service but still same issue.

1.  I tried SRVANY.exe and again it failed to start it as a service 'error2 the system cannot find the file specified'    -somthing to do with permissions ??

2. Pagent just saves you typing in the passphrase?  -  im already using Plink and the key has no passphrase.

3. ...aagh AlwaysUp is a pay for service,  need a license.... 30 day trial
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Spikeuk30Author Commented:
ok i have done it!  SRVANY.exe was the way to go, i had to export the registry settings where putty had saved them to my 'current_user' and moved them to the default so i could run the service with system account.

all done.
Daniel HelgenbergerCommented:
Nice! I waned to say something like this - the user running the service need all the details. A much more transparent way to do this and therefore recommended is using only command line options for plink and circumvent the registry altogether; this is what I ment when I posted this:

But it will work nevertheless!
Spikeuk30Author Commented:
After around an hour the ssh link drops - putty appears with an error? .  I have tried putting setting to keep alive in putty  but its still happening.

The ssh is between windows and ubuntu..
Daniel HelgenbergerCommented:
Hard to tell.
- Is this permanent?
- Check your windows service and plink process. Is it running?
- Is a SSH connection idle timeout specified?

For the time outs, there are two settings,
ClientAliveCountMax 99999

Open in new window

in /etc/ssh/sshd.conf
and for putty,
ServerAliveInterval 100

Open in new window

Choose either one, I recommend the latter.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SSH / Telnet Software

From novice to tech pro — start learning today.