SSH tunneling over tor

Viewed 136

Trying to connect to MySQL db via TOR proxy.

import paramiko
import MySQLdb

conf = paramiko.SSHConfig()
conf.parse(open('C:\ProgramData\ssh\sshd_config'))
host = conf.lookup('sql-tor')
print (host)

proxy = paramiko.ProxyCommand(host['proxycommand'])

client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(host["hostname"], username=host["user"], password='test', sock=proxy)

con = MySQLdb.connect(host='127.0.0.1', port=3306, user='user', password='password', connect_timeout=60)
cur = con.cursor()

client.close()

Getting this error:

Exception has occurred: FileNotFoundError
[WinError 2] The system cannot find the file specified
  File "test2.py", line 8, in <module>
    proxy = paramiko.ProxyCommand(host['proxycommand'])

sshd_config:

host *-tor
   CheckHostIP  no
   Compression  yes
   Protocol     2
   ProxyCommand connect -4 -S localhost:9050 $(tor-resolve %h localhost:9050) %p

Any ideas how I can create ssh tunnel over tor? Or any other variants to do this without tunneling?

0 Answers
Related