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 [email protected] ssh -L port2:localhost:port3 [email protected]
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
I get an error. In case the ~/.ssh/config is set in this way (my own try):
LocalForward port1 localhost:port2
LocalForward port2 localhost:port3
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:
LocalForward port1 user1@machine1:port2
LocalForward port2 user2@machine2:port3
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