Skip to content

Instantly share code, notes, and snippets.

@composite
Last active March 15, 2024 10:56
Show Gist options
  • Save composite/80c90af7c15f737e6ccd1a01fde829e9 to your computer and use it in GitHub Desktop.
Save composite/80c90af7c15f737e6ccd1a01fde829e9 to your computer and use it in GitHub Desktop.
Bitvise SSH Client as a Windows service with NSSM example.
@REM How to use before run this batch: You need Bitvise SSH Client and NSSM. if you haven't, google it and download and install.
@REM 1. open bitvise SSG Client
@REM 2. click "New Profile" to save profile.
@REM 3. configure SSH infomation, tunnels, etc.
@REM 4. click "Save Profile" to save profile.
@REM 5. on "sensitive" dialog popup, check "any account on this computer" or below to service account can connect it.
@REM 6. click "Login" to connect and test SSH Connection.
@REM 7. click "Accept & Save" if you see host key dialog popup.
@REM 8. Click "host key manager"
@REM 9. select your SSH host and click "Export". then click "Bitvise format" and save host key file.
@REM 0. that's it. then edit this file in your favorite editor to change profile and host key path. and RUN IT.
@SETLOCAL
@reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OS=32BIT || set OS=64BIT
@if %OS%==32BIT SET BITVISERUN=C:\Program Files\Bitvise SSH Client\log.exe
@if %OS%==64BIT SET BITVISERUN=C:\Program Files (x86)\Bitvise SSH Client\log.exe
@REM SET BITVISERUN=C:\Path\to\Bitvise SSH Client\log.exe
@SET LOGPREFIX=C:\path\To\log
@SET BVPROFILE=C:\path\to\profile.tlp
@SET BVHOSTKEY=C:\path\to\hostkey.pub
@REM you can change service name on "BitviseSSHClient" part.
nssm install BitviseSSHClient "%BITVISERUN%" -tcx "%LOGPREFIX%" stnlc -profile="%BVPROFILE%" -hostKeyFile="%BVHOSTKEY%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment