Running Bitvise SSH Client as a Windows Service

时间:2021-05-28 18:38:26

It is possible to run a Windows program as a system service. The advantage of services is that they can be started at boot time independently of any logon session, and will continue to run as users log on and off of the machine.

Frequently users would like to run Bitvise SSH Client as a service so that its port forwarding features would come into effect as soon as the machine boots and remain active regardless of users logging on and off of the machine.

Bitvise SSH Client itself does not run as a service, but it can be encapsulated inside a program that enables this. A few such programs we're aware of are:

  • The srvany utility included with the Windows Resource Kits. Guidance to using the srvany utility can be found in the MS Knowledge Base.
  • FireDaemon by Sublime Solutions. This may be easier to set up than srvany.
  • We have received suggestions for the Non-Sucking Service Manager by Iain Patterson.

Bitvise SSH Client supports command-line parameters which can tell it to load a desired profile and connect to the target server immediately. Information about the SSH client's command-line parameters is available from its log area immediately on start-up, as well as if you run Bitvise SSH Client from the command prompt with the /? parameter:

C:\>BvSsh /?

When configuring Bitvise SSH Client to run as a service this way, it must be set up to run under the Windows account of a user who has already used Bitvise SSH Client to connect to the target SSH server successfully. If this is not done and an arbitrary Windows account or the default Local System account is used, the SSH client will hang on verification of the server's public key fingerprint, and the session will not be established. Likewise, if the server's public key changes, you will need to login interactively into the account under which you are running Bitvise SSH Client as a service, and use the SSH client interactively to connect to the SSH server and verify and save its new public key.

So we choose  NSSM to make it as a window service:

nssm install BitviseSSHClient "D:\BitviseTunnelier\Tunnelier.exe" -profile="D:\BitviseTunnelier\Dev-Proxy-SG.tlp" -hostKeyFile="D:\BitviseTunnelier\Dev-Proxy-SG.hostKeyFile"  -loginOnStartUp 
net start BitviseSSHClient

If you want the remove this service :

nssm remove BitviseSSHClient confirm

or second solution :

0. Make sure you have saved your login and password in Tunnelier and it connects properly when you click Login
1. Find your shortcut icon for Tunnelier (or make one) and copy it on your desktop.
2. Right click on the shortcut and select "Propreties"
3. In the Shortcut tab, you will find a text box to the right of "Target"
4. Copy paste ["C:\Program Files\Bitvise Tunnelier\Tunnelier.exe" -loginOnStartUp], without the [] in the text box.
5. Click apply and exit.
\\now
whenever you click on your edited shortcut, Tunnelier will open in the
background, and login automatically. You will see the icon appear in
your system tray but now new window will open.)
\\we will now make Tunnelier start when Windows starts.
6.
Go in your Start Menu, and find the "Startup" folder. This can be found
by clicking on "All Programs" and scrolling down the list until you
find it, at least in Windows 7 and Vista.
7.Once you found your Startup folder, right click on it and select Explore or Explore All users
\\If
you select Explore, you are only going to affect programs that start up
automatically with the username that you are currently logged in with.
If you select Explore All Users, you will affect that startup of all
users...
8. Copy your edited shortcut of Tunnelier that is placed on your Desktop to the "Startup" folder.
9.Enjoy.

Reference :

Bitvise Tunnelier, a fully featured SSH2 client.
Copyright (C) 2000-2005 by Bitvise Limited.
Portions Copyright (C) 1995-2003 by Wei Dai. The following parameters are currently supported.
-profile=xxx: the profile to open on startup
-host=xxx: the SSH host to connect to, overrides profile
-port=xxx: the port on the SSH host to connect to, overrides profile
-username=xxx: specifies the username to use, overrides profile
-password=xxx: specifies the password to use, overrides profile
-loginOnStartup: instructs Tunnelier to login immediately
-exitOnLogout: instructs Tunnelier to exit after logging out
-hide=xxx: specifies a comma-separated list of functionality to hide
main: Tunnelier's main window
hostKey: host key confirmation dialog
banner: user authentication banner message
auth: user authentication dialog
popups: log popup balloons
trayLog: show log system tray menu
trayWRC: WinSSHD Remote Control system tray menu
trayTerm: open new terminal system tray menu
traySFTP: open new SFTP window system tray menu
trayRDP: open new Remote Desktop system tray menu
trayPopups: log popup settings system tray menu
-menu=xxx: the scope of system tray menu functionality made available
full: allow full access - normal use
small: same as -hide=main,trayWRC,trayTerm,traySFTP,trayRDP
min: same as -menu=small -hide=hostKey,popups,trayLog,trayPopups
-noRegistry: do not load settings from or store them to Windows registry
-proxy=y|n: use a proxy server, overrides global client proxy settings
-proxyType=xxx: the type of proxy server to use
SOCSK4: a SOCKS4 or 4A proxy (default)
SOCKS5: a SOCKS5 proxy
HTTP: a proxy supporting the HTTP CONNECT verb
-proxyServer=xxx: the IP address or DNS name of the proxy server
-proxyPort=xxx: the proxy server port, 1080 by default
-proxyUsername=xxx: proxy server username (SOCKS5 and HTTP only)
-proxyPassword=xxx: proxy server password (SOCKS5 and HTTP only)
-proxyResolveLocally: whether to resolve a DNS name locally before passing it to the proxy
-hostKeyMD5=xxx: MD5 fingerprint of the host key to accept, used additionally to global client host key database
-hostKeyBB=xxx: Bubble-Babble of the host key to accept, used additionally to global client host key database
-hostKeyFile=xxx: a file containing host keys to accept, used additionally to global client host key database
-keypairFile=xxx: a file containing a private key for authentication; overrides keys in global client user keypair database
-keypairPassphrase=xxx: must be present when -keypairFile specifies an OpenSSH encoded and passphrase protected keypair All parameter names are case sensitive.