要连接到我办公室的电脑,我需要运行两次ssh。 首先连接到主机1,然后从主机1连接到主机2,每个人拥有不同的凭证。 然而,Pycharm中的配置菜单只接受一个ssh隧道。
配置远程Python解释器对话框
有什么办法可以设置多跳ssh来访问本地主机上的解释器和数据文件吗?
To connect to the computer at my office I need to run ssh twice. First to connect to the host-1 and then from host-1 to host-2 and each one has different credentials. However the configuration menu in Pycharm only accepts one ssh tunnel.
Configure Remote Python Interpreter dialog box
Is there any way to set a multi-hop ssh to have access to the interpreter and data files on the host from local?
最满意答案
您可以在ssh上使用端口转发。 如果本地系统为A ,则下一个ssh跳为B ,目标跳为C ,打开终端并运行:
ssh -L 6000:<server C IP>:22 <user_serverB>@<server B IP>您可以用任何端口替代6000。 现在你可以在另一个终端上的ssh服务器上用:
ssh -p 6000 <user_serverC>@localhost请记住不要关闭第一个终端!
PyCharm也是如此。 只需使用以下配置通过ssh设置远程解释器连接:
主机:localhost 端口:6000 user:user_serverCYou can use port forwarding on ssh. If local system is A, the next ssh hop is B, and the target hop is C, open a terminal and run:
ssh -L 6000:<server C IP>:22 <user_serverB>@<server B IP>You can substitute 6000 with any port. Now you can ssh into the ssh server on C on another terminal with:
ssh -p 6000 <user_serverC>@localhostKeep in mind not to close the first terminal!
The same goes for the PyCharm. Just set the remote interpreter connection through ssh with the following configuration:
host: localhost port: 6000 user: user_serverC更多推荐
发布评论