今天问了一下搞运维的,说可以配置config文件来进行端口转发,然后我就自己学习了一波,发现非常的好用,这里分享出来给大家。
首先打开命令行,输入:
vim ~/.ssh/config
按键i,然后输入:
Host exampleHostName ip_addressUser host_nameLocalForward 7474 127.0.0.1:7474LocalForward 7777 127.0.0.1:7777
按键Esc, 然后:wq保存,配置完以后,在命令行里面输入:
ssh example
就可以自动进行端口映射配置了
参考文献
[1].SSH Port forwarding in a ~/.ssh/config file? [closed]./questions/9146457/ssh-port-forwarding-in-a-ssh-config-file
[2].OpenSSH Config File Examples.https://www.cyberciti.biz/faq/create-ssh-config-file-on-linux-unix/