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?
Related
I am trying to connect to remote machine by python script. Both the machines can be linux/windows.
I have to connect to various remote machines and it's not feasible for me to install or write some code on the remote side. I know the ip, username and password of the machine and i tried various options but was unsuccessful.
How shall I proceed.
Maybe you can use SSH to connect to a remote server.
paramiko will be good idea, it can use to connect linux/windows.
http://pxnet2768.pixnet.net/blog/post/157228756-%E7%B3%BB%E7%B5%B1%E9%81%8B%E7%B6%AD%E5%B7%A5%E7%A8%8B%E5%B8%AB%E7%9A%84%E6%B3%95%E5%AF%B6%EF%BC%9Apython-paramiko
I am writing some python code to query a remote sql database. I can do this in a command line by setting up port forwarding and, in a different shell, running a mysql server. However I cant think of a way of doing this in python - is there a python module which would set up port forwarding, then return control back to the python script (and even better if I can periodically check to see if the port forwarding is still active!) TIA, Jack
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.
I have try to implement it using paramiko. But I find paramiko can only launch a tunnel redirecting localhost:lport to remoteip:rport just like 'ssh -L'.
So I want to know how can I implement it using paramiko or use other library.
Thanks for your help.
Unlike the -L or -R options which forward specific ports, ssh -D establishes a SOCKS proxy for application-level port forwarding.
Assuming that's what you want, then according to this answer, there are several Python modules which implements SOCKS clients/proxies, e.g. PySocks and SocksiPy. Unfortunately, I have never explored any of these options and cannot vouch for any of them.
I used to create a SOCKS connection between a windows client and linux server using SSH server and putty. However, the firewall between the client and server is now able to identify SSH packets and drop them.
I was wondering if I can emulate such behavior of SSH tunnels using python? Any recommendations on libraries or readings?
Thanks in advance.
Yes, yes you can. Pick your poison.
http://socksipy.sourceforge.net/
http://sourceforge.net/projects/pysocks/
http://code.google.com/p/socksipy-branch/
How can I use a SOCKS 4/5 proxy with urllib2?
http://google-api-python-client.googlecode.com/hg/docs/httplib2.socks.html
You can consider using paramiko for your SSH. Here is a nice link ssh-programming-with-paramiko
You can also try this ssh module which uses paramiko.