PyCharm:通过SSH配置多跳远程解释器(PyCharm: Configuring multi

编程入门 行业动态 更新时间:2024-10-28 00:16:43
PyCharm:通过SSH配置多跳远程解释器(PyCharm: Configuring multi-hop remote Interpreters via SSH)

要连接到我办公室的电脑,我需要运行两次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_serverC

You 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>@localhost

Keep 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

更多推荐

本文发布于:2023-04-27 16:42:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1327337.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:跳远   SSH   PyCharm   Configuring   multi

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!