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/
Related
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?
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.
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.
Things to note in advance:
I am using wampserver 2.2
Ive forwarded port 80
I added a rule to my firewall to accept traffic through port 3306
I have added "Allow from all" in directory of "A file i forget"
My friend can access my phpmyadmin server through his browser
I am quite the novice, so bear with me.
I am trying to get my friend to be able to alter my databases on my phpmyadmin server through
python. I am able to do so on the host machine using "127.0.0.1" as the HOST. My Question is, does he have to use my external ip as the HOST or my external ip/phpmyadmin/ as the HOST? And if using the external ip iscorrect...What could the problem be?
If your phpmyadmin runs on the same machine as mysql-server, 127.0.0.1 is enough (and safer if your mysql server binds to 127.0.0.1, rather than 0.0.0.0) if you use tcp(rather than unix socket).
I am trying ldap authentication. My ldap server is located at x.x.x.x . I am using python-ldap. Connection on server locally doing:
ldap.initialize('ldap://localhost:389')
works fine,
but when i try to connect to the server from another machine, doing:
ldap.initialize('ldap://x.x.x.x:389')
it doesnt work.
What is it that I should do?
This was resolved by way of lifting firewall-based restrictions.