PyCharm: Configuring multi-hop remote Interpreters via SSH

2024/11/18 20:02:59

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?

Answer

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
https://en.xdnf.cn/q/26525.html

Related Q&A

Return results from multiple models with Django REST Framework

I have three models — articles, authors and tweets. Im ultimately needing to use Django REST Framework to construct a feed that aggregates all the objects using the Article and Tweet models into one r…

Comparing XML in a unit test in Python

I have an object that can build itself from an XML string, and write itself out to an XML string. Id like to write a unit test to test round tripping through XML, but Im having trouble comparing the tw…

Passing a tuple as command line argument

My requirement is to pass a tuple as command line argument like --data (1,2,3,4)I tried to use the argparse module, but if I pass like this it is receiving as the string (1,2,3,4). I tried by giving ty…

Setting exit code in Python when an exception is raised

$ cat e.py raise Exception $ python e.py Traceback (most recent call last):File "e.py", line 1, in <module>raise Exception Exception $ echo $? 1I would like to change this exit code fr…

cmake error the source does not appear to contain CMakeLists.txt

Im installing opencv in ubuntu 16.04. After installing the necessary prerequisites I used the following command:-kvs@Hunter:~/opencv_contrib$ mkdir build kvs@Hunter:~/opencv_contrib$ cd build kvs@Hunte…

Overlay an image segmentation with numpy and matplotlib

I am trying to overlay two images. The first one is a 512x512 NumPy array (from a CT image). The second one is also a 512x512 NumPy array but I am just interested in the pixels where the value is large…

Why isnt my variable set when I call the other function? [duplicate]

This question already has answers here:How do I get ("return") a result (output) from a function? How can I use the result later?(4 answers)How can I fix a TypeError that says an operator (…

Return max of zero or value for a pandas DataFrame column

I want to replace negative values in a pandas DataFrame column with zero.Is there a more concise way to construct this expression?df[value][df[value] < 0] = 0

Getting str object has no attribute get in Django

views.pydef generate_xml(request, number):caller_id = x-x-x-xresp = twilio.twiml.Response()with resp.dial(callerId=caller_id) as r:if number and re.search([\d\(\)\- \+]+$, number):r.number(number)else:…

Cython Speed Boost vs. Usability [closed]

Closed. This question is opinion-based. It is not currently accepting answers.Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.Clo…