Python: SSHTunnel and Socks5 server - python

I'm trying for the last couple of hours to find a solution of tunneling a SSH connection and create a Socks5 server on that SSH tunnel, so I can browse a webpage with Selenium.
For connecting to remote SSH, I've been using sshtunnel. I managed to connect to the remote SSH server. Now I'm trying to create a SOCKS5 server on that connection so I can use it with FireFox.
I'm exhausted, have been searching for at least 4 hours and no result.
What should I look for? Did anyone create a Socks5 server from a SSH Tunnel?

Related

How to forward a Kerberos ticket over SSH using Paramiko?

I'm trying to forward a Kerberos ticket over SSH connection to keep using an authenticated session in Hive/Beeline.
I already do this by PuTTy, but I couldn't with Paramiko.
Someone knows if is possible to forward a Kerberos ticket over SSH using Paramiko? And how can I do that?
PS: Windows 10 client connected to a Linux Server.

Connection to Remote Machine using python script

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

How to use python to connect to linux port

I am now facing the problem with using python to connect to one port which requires username/password.
The web URL is xxx.xxx.xxx.xxx:9200/_plugin/head/, which is for elasticsearch. I think the administrator has set firewall for the port, when I want to log in with web browser, the web browser will require username/password, if wrong, the web page will show "authentication failed". And when I use another Linux server to use query port directly with command like
curl -XPOST 'xx.xx.xxx.x:9200/iqas_week/_search?pretty=true' -d ...
The server will also return "Authentication Required"
My plan is to use python to connect to this port and write some query for elasticsearch just like the code above. Now with encrypted port, how can I connect to that port in python? I have tried with paramiko, it works for port 22 but not for port 9200, is there any other way to connect to this port using python?
You should be able to use urllib2 to connect to the elasticsearch listener as I believe it's just an HTTP(s?) listener. Why not use the elasticsearch though?
https://elasticsearch-py.readthedocs.io/en/master/

Python connect to ssh mysql server

I'm writing a small python program locally as i don't have root access on the server. It basically does a lot of mysql queries using python MySQLdb module.
The thing is I cant use MySQLdb with the server, as the mysql server is hosted locally and I need to ssh into the server and then use mysql from there.
Is there any module available where I can connect to a mysql database via SSH.
At the moment I can connect to the mysql instance using SSH credentials (IP, User, Pass)
I also have the user/pass for the mysql instance and I'm pretty sure it runs on 127.0.0.1/localhost.
If you're set on Python, I would use paramiko:
https://github.com/paramiko/paramiko
This seems to be one of the most widely used Python SSH libraries. There are some other StackOverflow questions that address how to do this.
How to open an SSH tunnel using python?
SSH Tunnel for Python MySQLdb connection
The main idea is to create a tunnel with paramiko and then connect to the localhost port through which you are tunneling traffic to the remote server using the Python library MySQLdb.

Python Proxy Through SSH

I'm being trying to
Log into a server using SHH (with Paramiko)
Use that connection like a proxy and route network traffic through it and out to the internet. So say I could set it as my proxy in Urllib2, Mechanize, Firefox, etc.).
Is the second part possible or will I have to have some sort of proxy server running on the server to get this to work?
You could implement a SOCKS proxy in the paramiko client that routes connections across the SSH tunnel via paramiko's open_channel method. Unfortunately, I don't know of any out-of-the-box solution that does this, so you'd have to roll your own. Alternatively, run a SOCKS server on the server, and just forward that single port via paramiko.

Categories

Resources