sshportforwardingssh-tunnelwebmin

SSh tunnel connection refused, but establish ssh connection in terminal


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:

  1. write the local port to open in source port: 10005 and IP address:port of remote azure vm
  2. selected my private key .ppk file in ssh > auth > credential
  3. in the session tab I put the IP address of my azure vm

SSH tunnel with putty vm IP

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


Solution

  • 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