SSH Port forwarding in a ~/.ssh/config file?

LinuxMacosUnixSsh

Linux Problem Overview


So I typically run this command a lot:

> ssh -L 5901:[email protected]:5901

I use it to do VNC over SSH.

How do I convert that command into something that will work in a ~/.ssh/config file?

ex:

host yam
	HostName yam.myHost.edu
	User myUserName

all I want to do is type:

ssh yam

And have it open a SSH shell with a local listen port, and a remote port forwarded to it.

Suggestions?

Linux Solutions


Solution 1 - Linux

You can use the LocalForward directive in your host yam section of ~/.ssh/config:

LocalForward 5901 computer.myHost.edu:5901

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSnow_MacView Question on Stackoverflow
Solution 1 - LinuxJohnsywebView Answer on Stackoverflow