I need to create a SSH tunnel to connect to webmin gui hosted in a Azure virtual machine. I can connect to the vm via ssh from PuTTY. The private key run and can establish the connection. But when I try to create the tunnel to access webmin throw localhost in browser I can't.
Tried to establish the tunnel with PuTTY:
When I click on open, I can connect to ssh terminal when I digit myuser
but in the browser can't access the webmin with localhost:10005
"ERR_CONNECTION_REFUSED"
I tried with plink with the command:
plink.exe mykey.ppk -L 10005:localhost:10000 myuser@xx.xxx.xx.183
but the response was:
Unable to open connection:
Host does not exist
I tried with sshopen client in Powershell with the command:
ssh -L 10005:localhost:10000 myuser@xx.xxx.xx.183
but the response of the server was:
myuser@xx.xxx.xx.xxx: Permission denied (publickey).
What is missing? Thank you any help
Finally I found the solution using plink.exe The right command is this:
"C:\Program Files\PuTTY\plink.exe" -ssh serverUser@serverIP -P 123 -i "path-to-my-key\myprivatekey.ppk" -C -T -L 10000:127.0.0.1:10000 -N
In this command options are:
-i: the path where I stored my private key
-P: the port of the ssh service in the remote machine, necessary only if the port is different to the default one (22)
-C: enable data compression.
-T: avoid opening terminal.
-L: forward le local port
-N: do not execute commands in remote machine
It is possible to set the plink.exe path directly in the Windows’s PATH variable environment:
set PATH=%PATH%;C:\Program Files\PuTTY\plink.exe
In that way there is no need to write the plink.exe path in the command every time:
plink.exe -ssh serverUser@serverIP -P 123 -i "path-to-my-key\myprivatekey.ppk" -C -T -L 10000:127.0.0.1:10000 -N