How to add local forward setting to my ssh config file?
I currently can do this:
ssh 12.34.56.78 -L 8888:localhost:8000
And I can then open my local browser to localhost:8888 and see the app running in my server at 12.34.56.78:8000.
I want to avoid having to type in that forward command and instead place that config in my ssh config file.
Currently I have this:
Host myhost
User myuser
Hostname 12.34.56.78
IdentityFile ~/.ssh/id_rsa
LocalForward 8888 12.34.56.78:8000
I thought it would work the same, but when I ssh into myhost
as I usually do, and then try to open my browser to localhost:8888, I can no longer see the app running and I get these messages in myhost console:
channel 4: open failed: connect failed: Connection refused
channel 3: open failed: connect failed: Connection refused
channel 3: open failed: connect failed: Connection refused
channel 4: open failed: connect failed: Connection refused
channel 3: open failed: connect failed: Connection refused
I guess I can just add an alias to run the ssh command and be done with it, but I was hoping to have this properly setup in my config file, and, if being able to see my app running in my browser without having to ssh into my host can be achieved could be a huge plus.
Anyone can help with this?
The syntax of the ssh_config file was correct - so the error had to be somewhere else. The command line which worked was:
ssh 12.34.56.78 -L 8888:localhost:8000
but in the LocalForward
directive, you used the "real" IP address. Obviously, the app just listened to localhost - either change the listen interface in the app, or adapt the ssh_config file to use localhost, too.