Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
530 views
in Technique[技术] by (71.8m points)

python - PyCharm: Configuring multi-hop remote Interpreters via 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use port forwarding on ssh.

1. Open a terminal and run:

On your local system:

ssh -L 6000:<target_server_ip>:22 <proxy_server_user>@<proxy_server_ip>

You should be connected to the proxy now. You can substitute 6000 with any port.

2. (optional) Test

Now you can ssh into the target server on another terminal with:

ssh -p 6000 <target_server_user>@localhost

3. Configure PyCharm

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: target_server_user

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...