Article Title: how to configure port forwarding using OpenSSH in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Accessing the company's CVS server from your computer requires the port forwarding function of the SSH client. Previously in Windows, SecureCRT was generally used as the SSH client. After that, I migrated my work platform to Ubuntu Linux, but I could not find a way to directly Configure port forwarding using OpenSSH. I only know how to use PuTTY Tunnel to do this, but I feel a little awkward when I open an application but only do port forwarding.
Coincidentally yesterday, I accidentally found some articles about OpenSSH port forwarding configuration. The following example shows how to configure the port forwarding function of OpenSSH. The configuration file to be modified is ~ /. Ssh/config.
Host testsrv Hostname 123.45.67.89 User cvs_user LocalForward 2401 123.45.67.90: 2401
The Host is followed by the Host name. After this name is specified, you can use this name to replace the Host's IP address. For example:
Ssh testsrv
Equivalent
Ssh 123.45.67.89
The User is the User name used to connect to the host.
LocalForward is used to configure the port forwarding function. 2401 indicates the local port number. 123.45.67.90: 2401 is the IP address and service port of the CVS server (that is, the target host and port of the forwarding ). LocalForward indicates that the local port is used for forwarding. If you want to use a remote port for forwarding, The RemoteForward parameter is used. After the configuration is complete and the connection to the host testsrv is successful, a secure SSL encryption channel is established.
Note that in some articles
(1) 2401 123.45.67.90: 2401
Written
(2) 2401: 123.45.67.90: 2401
The format shown in (2) is the format used to directly Configure port forwarding Parameters Using ssh on the terminal. For example
Ssh-L 2401: 123.45.67.90: 2401 cvs_user@123.45.67.89
It is also equivalent to the content configured in the configuration file.