0

I have a dedicated server. There's a VNC Server and I can connect to VNC Server with a VNC Client with port 5901 so it takes me to display :1 when I connect there with a VNC Client.

I've read pretty many documents about ssh -L and ssh -R command-line commands, but it's pretty weird, because they have servers and such on their own machines and on their remote machines so I get confused about that where are they even trying to connect and what etc.

  1. I have dedicated server with VNC Server, Web Server, Game Server and Firewall.
  2. VNC Server is running and TCP/UDP connection has been enabled only to ports of Web Server, SSH, Game Server.
  3. I want connect to my VNC Server with my VNC Client (from my own pc), but using a tunneled connection, because people are trying my password too many times or something, because sometimes it says "Too many authentication failures" what a tards they are, because they will never guess the password. Anyways. I have tried similar:

ssh root@DEDICATEDIP -L 5901:DEDICATEDIP:5901 ssh root@DEDICATEDIP -R 5901:DEDICATEDIP:5901

I also tried this one (found from this site): ssh -L 5901:localhost:5901 -p 22 root@DEDICATEDIP

If I write "su" in SSH and I write my root password I can get in with root account, but when it asks my root password on ssh after trying to fill any of these tunneling commands it says the password is wrong and permission denied?

Edit:

  • My PC: PuTTy (SSH Client), VNC Viewer (VNC Client)
  • Dedibox: VNC Server, GameServer, Web Server, SSH Server

ufw status

  • 22 - ALLOW - Anywhere
  • 22 - ALLOW OUT - Anywhere

VNC Server is running and I can confirm that. If I add 5901 to ALLOW and ALLOW OUT I can simply connect there without a tunneling.

  1. (My PC) Open PuTTY
  2. (My PC) PuTTY Configuration -> Connection -> SSH -> Tunnels

    • Source port [5902]
    • Destination [163.xxx.xxx.xxx:5901]
    • [ADD]
  3. Now PuTTY shows "Forwarded ports: " -> "L5902 163.xxx.xxx.xxx:5901"

  4. I connect to server with SSH including the Tunnel settings I've configured now.
  5. I type "su" and I submit my root password.
  6. root@MyBox: /home/sysadmin# (sysadmin is normal user for my box)
  7. I type: "ssh root@IP_OF_DEDI -L 127.0.0.1:5902:127.0.0.1:5901"
  8. VNC Client keeps connecting for a while. Like (15 seconds) and says: "The connection was refused by the computer"

bumped to the homepage by Community 13 hours ago

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

0

Try the following:

start the vnc server on ip 127.0.0.1, port 5901

use the command ssh user@vncserver -L127.0.0.1:5902:127.0.0.1:5901 to start the tunnel

then connect to 127.0.0.1:5902 with your local vnc client.

This gives you the advantage of running the vnc server only on the loopback interface on the remote side.

  • Ok. It's on 127.0.0.1 and 0.0.0.0, but the command doesn't make the magic. By submitting this command from PuTTy (SSH) client connected to dedicated server doesn't make any difference. Only what it does it prompts me type a root password and by typing it, it just "login" back as normally. Connecting with 5902 doesn't redirect me anywhere. Says after a while "connection refused", but if I type this same command again it will say that address is already binded so basically the command works (I guess?) – Weird E. Nov 24 '16 at 14:54
  • Did you set up the tunnel in putty settings? You need to do local forward from 127.0.0.1:5902 to 127.0.0.1:5901 on the remote side – gerhard d. Nov 24 '16 at 15:03
  • I didn't made any changes to PuTTy's settings in it's configuration. I connected with SSH and logged in as root and sent the command via SSH. So basically I have to make settings in PuTTy settings in Tunneling section and connect to SSH and after that execute the command you provided? – Weird E. Nov 24 '16 at 15:06
  • I added settings in tunnel section of PuTTY to Source: 5901 - Destination: DEDIBOX_IPADDR:5901 in PuTTy GUI, Connected to SSH, tried connect with VNC client, tried also type: ssh root@DEDIBOXIP -L 127.0.0.1:5902:127.0.0.1:5901, doesn't show a message that the port is already binded, tried VNC client, Nope. – Weird E. Nov 24 '16 at 16:00
  • You just need ONE ssh connection. With the -L -option or tunnel settings in putty, you have a forward of your local port to the remote 5901 port, which is vnc. Do not create an additional ssh session, it is not needed. – gerhard d. Nov 24 '16 at 16:29
-1

If you are using Putty then you can set up the tunnel for a session in the Connection > SSH > Tunnels tab. Make the source port L5902 and the Destination 127.0.0.1:5901.

You will need to set up the session to save these details. This will have you connecting to vnc window 1.

From command line you can use ssh -L5902:127.0.0.1:5901 user@target this does the same thing as what putty is doing i believe.

I dont know enough to give much more of an explanation to this.

  • Welcome to Unix & Linux! While this code snippet may solve the question, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, not just the person asking now! Please edit your answer to add explanation, and give an indication of what limitations and assumptions apply. – Toby Speight Nov 24 '16 at 15:48
  • Doesn't work. I will update my question soon to add as much possible information I can find. – Weird E. Nov 24 '16 at 16:04
  • Can you not reach your target box without going to MyBox first? If you cant then you need to change the destination of the putty session to the ip of IP_OF_DEDI:5901 and run it again the vnc client should be a vnc session on IP_OF_DEDI and not on MyBox – a.smith Nov 24 '16 at 17:25
  • MyBox is just name of my dedicated if I login it's anyofmyusers@MyBox, but at the moment I cannot reach anything else than SSH, because I have only port 22 open. – Weird E. Nov 24 '16 at 21:18
  • port 5901 needs to be open to be able to get the vnc session. – a.smith Nov 25 '16 at 9:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.