Pycharm Remote Python Interpreter over SSH Gateway, X11 forwarding - python

I want to configure PyCharm 3.0 to use a Remote Python Interpreter.
The Problem is, I have to connect over a SSH Gateway:
MyMachine -> Gateway -> Machine with Python
When I connect via Cygwin I type the following: ssh -t user#gateway.com "ssh user#machineWithPython.com"
Is there a way to achieve this in PyCharm?
Another question, can I forward the X11 server to PyCharm (so that I can view the matplotlib plots on my machine?)
Regards,
m

I was able to the piggyback X11 forwarding through another ssh connection. Try setting the DISPLAY environment variable in your PyCharm run configuration like so:
DISPLAY=localhost:102
Check the value of DISPLAY in the other connection to see exactly what the value should be.

I am not sure I have understood your question correctly, it is maybe more adequate for the UNiX/Linux part.
At you machine:
ssh -fN -L 2222:machinewithPython:22 \ user#gateway.com
This connects port 2222 on your local machine to port 22 on remotemachine, and the ssh tunnnel will remain open until you kill the ssh process.
See the following links here and there.

Related

Port forwarding in python: why not just use ssh -L?

At [TO_PORT] on the server [TO_ADDRESS] is something I would like to connect with (Theia IDE). Using Linux I can simply do: ssh -L [FROM_PORT]:localhost:[TO_PORT] [TO_ADDRESS]. Now I can access the Theia IDE using localhost:[FROM_PORT].
When researching how to do port forwarding in a python program I found many solutions and all looked quite bulky. Why do people implement their own port forwarding and not use the ssh command?

How to create directory in remote system using python script

I want to create a directory in my remote system using python script or by socket programming. I have remote system's Username, password and IP address. I am able to do this in my local machine but not in remote. Please help!
Download Putty then connect to remote system) and in terminal write mkdir foldername
To create a directory on a remote machine, you will have to first connect to it.Telnet and SSH and SSH is used to connect to remote machines. Obviously TELNET or SSH service should be running on the remote machine, otherwise you won't be able to connect.Since in case of Telnet,data is transfered in plain text, it's better to use SSH protocol.
Once connected to the remote machine using SSH, you will be able to execute commands on the remote machine.
Now since you want to do everything in Python, you will have to write a complete SSH client in Python. Which is greate for learning, because you will learn about socket programming and cryptography.
If you are in a hurry, you can use a good SSH library.
If you are getting network connection error, please check whether SSH is installed in the remote machine or not. If yes, then check firewall settings.

PyCharm remote debug using remote container Python interpreter

My situation is that I have set up a container in a remote server, and inside the container, there is a virtual environment. I'm using the python interpreter inside this virtual environment in this container, not the one on the host.
From my local machine, I can open up PyCharm, and use Tools->Deployment->Configuration to easily set up a remote connection. And For a specific project, I can set up the interpreter by clicking Files->Settings->Project Interpreter. However, it seems that I can only select the host Python interpreter(/usr/bin/python) on the remote server, not the one inside the virtual environment in the container. How could I set up using this interpreter?
I googled but can't find exact solution. I don't think I need to install Docker locally because my Docker is on the remote server side, right?
In similar way you are connecting to remote host - you would need to setup container with same capabilities e.g. set ssh server running on there. Then you should expose the port into public world or use nested ssh tunnel, which would be better alternative.
Another interesting approach (maybe recommended) is to forward Docker socket from the remote machine so, that you local Docker CLI uses this socket for sending commands to remote host. Theoretically, then you could add this container directly in PyCharm, when you set correct Docker host address there.
Further, virtual environments on other than local host systems are not supported natively by PyCharm. However, you could try to add path of python and see if it works e.g. venv/bin/python from project directory.

Can't access python server started in Windows 7 from another PC

I have two computers in the same enterprise network. The one with Windows XP (IP 192.168.101.96) and the other with Windows 7 (IP 192.168.101.98).
If I start Django project on PC with Windows XP (python manage.py runserver 192.168.101.96:8001), I can easily access it from Windows 7 PC with browser.
But the opposite way doesn't work. If I start Django project on PC with Windows 7, I can't access it from Windows XP PC.
The same situation is with command python -m SimpleHTTPServer 8001.
I tried to add a rule for external connections on TCP port 8001 in Windows firewall settings. Also I tried to add python.exe to firewall exceptions, but nothing seems to work...
It should be noted that when I start Django server and execute NETSTAT -p tcp -ano command, I can see line:
TCP 192.168.101.98:8001 0.0.0.0:0 LISTENING 6920
But nevertheless, nothing work. What can be the source of the problem?
for access to another computer server , server must be run on port 80.
you must run django server on port 80
python manage.py runserver 0.0.0.0:80
then access with type ip in the browser without post number :
http://192.168.101.98/
good luck
The problem was in ESET Endpoint Security special firewall. It's "automatic mode" blocks traffic without any promt to user. The problem can be solved by adding special rule to this firewall or changing it's main policy to "interactive mode" for example.

open an ssh tunnel from heroku python app on the cedar stack?

Is it possible to open a non-blocking ssh tunnel from a python app on the heroku cedar stack? I've tried to do this via paramiko and also asyncproc with no success.
On my development box, the tunnel looks like this:
ssh -L local_port:remote_server:remote_port another_remote_server
Can you please post the STDERR of ssh -v -L .....? May be you need to disable the tty allocation and run ssh in batch mode.
This recipe ought to work with Python (even though it was for a Rails app). Here's the recipe: https://stackoverflow.com/a/27361295/558639
The biggest challenge is convincing ssh to not prompt when it starts up.

Categories

Resources