背景
vscode目前是非常流行的编程工具,提供了大量的插件,尤其是其中的remote–ssh,能够提供远程ssh连接服务器,居家办公两不误。
然而比较麻烦的事情是,通常服务器为了保证安全都会设置多级jumpserver,较少情况下才会提供直连。
因此本篇博客的主要目的就是在remote-ssh里达到多级跳转。
参考
https://code.visualstudio.com/blogs/2019/10/03/remote-ssh-tips-and-tricks#_proxycommand
方法
安装好remote-ssh后,在confit文件里安装以下配置,即可达到jump1->jump2->target
的目的,其中只有jump1
在公网可以访问。·
# Read more about SSH config files: https://linux.die.net/man/5/ssh_config
# Jump box with public IP address
Host jump1
HostName ip_of_jump1
Port port_id
User user_name
IdentityFile key_path
Host jump2
HostName ip_of_jump2
Port port_id
User user_name
IdentityFile key_path
# command line, setting jump1
ProxyCommand ssh -q -W %h:%p jump1
# Target machine with private IP address
Host target
HostName ip_of_target
Port port_id
User user_name
IdentityFile key_path
ProxyCommand ssh -q -W %h:%p jump2
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)