Create ssh config to VNC server with tunnel via intermediate machine
0
votes
1
answer
431
views
I recently found out about ssh config file where one can setup frequently used ssh connections. However, I am having troubles transforming one command which connects my computer to VNCServer running on my server which is hidden behind intermediate server. Basically transform this command (which works):
ssh -t -L port1:localhost:port2 user1@machine1.com ssh -L port2:localhost:port3 user2@machine.com
with vncviewer localhost:0
in separate window, into ssh config file. I managed to create a config which connect to the machine without throwing any Failed to set up port
messages, but when I run in separate terminal window
vncviewer localhost:0
I get an error. In case the ~/.ssh/config is set in this way (my own try):
Host machine1
HostName machine1.com
User user1
LocalForward port1 localhost:port2
RequestTTY force
Host machine2
HostName machine2.com
User user2
LocalForward port2 localhost:port3
ProxyJump machine1
and ran by running ssh machine2
and then vncviewer localhost:0
in new terminal window the error is "Failed to connect to localhost:0": unable to connect to socket: Connection refused (111).
In the case I set it up as mention [here](https://unix.stackexchange.com/questions/303993/reverse-ssh-tunnel-in-with-ssh-config) :
Host machine2
HostName machine2.com
User user2
LocalForward port1 user1@machine1:port2
LocalForward port2 user2@machine2:port3
RequestTTY force
I get an error saying The connection was dropped by the server before the session could be established.
In both cases I connect to machine2 in terminal window and can browse stuff. But I would like to connect to the vncserver also.
Can you please explain what am I doing wrong here? I was consulting these sources when creating any other ssh config:
https://linuxize.com/post/using-the-ssh-config-file/ --- beginners guide
https://man7.org/linux/man-pages/man1/ssh.1.html --- to look definition of every -t -L I used
https://phoenixnap.com/kb/ssh-config --- to translate -t -L to ssh config command
https://www.ssh.com/academy/ssh/tunneling-example --- to explain wheter I need LocalForward or Remote Forward
Asked by Arual
(3 rep)
Sep 10, 2023, 08:33 AM
Last activity: Sep 10, 2023, 12:09 PM
Last activity: Sep 10, 2023, 12:09 PM