SSH/SFTP connection via a SOCKS5 proxy
See original GitHub issueHi, thanks so much for the library.
Apologies if what I’m asking has been answered elsewhere. I’ve read through the docs and searched issues, but cannot find an answer to my question.
I’m trying to connect to an SFTP server via a SOCKS5 proxy (the client is running on heroku so needs to use a proxy like this to connect to a server which needs a static IP to whitelist).
I’m wondering if this is something asyncssh is able to do?
The only mention I can find of something related is forward_socks
but that seems to be related to creating a socks proxy, not connecting through one.
To make the question more concrete, here’s an example using paramiko and socks of what I’m trying to do with asyncssh:
import paramiko
import socks
def with_paramiko():
sock = socks.socksocket()
sock.set_proxy(
proxy_type=socks.SOCKS5,
addr=proxy_host,
port=proxy_port,
username=proxy_username,
password=proxy_password,
)
sock.connect((server_host, 22))
transport = paramiko.Transport(sock)
transport.connect(username=server_username, password=server_password)
client = paramiko.SFTPClient.from_transport(transport)
try:
# do lots of stuff here
print(client.listdir('/root/'))
finally:
client.close()
transport.close()
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
shell - SFTP using SOCKS proxy command with password ...
According to Is there a built-in way to proxy SSH through socks5?, this should do: sftp -o ProxyCommand='ncat --proxy-type socks5 ...
Read more >Tunneling through proxy & SSH server - Unix Stack Exchange
I tried connecting through proxy option and SSH tunneling option in Winscp but the problem is as below: The SOCKS5 proxy is used...
Read more >how to sftp using a SOCKS v5 proxy - LinuxQuestions.org
This is an old post. Thought my input will help subsequent visitors to this forum. Below is the command I used to connect...
Read more >Java SFTP using SOCKS Proxy - Chilkat Example Code
Demonstrates how to connect to an SFTP/SSH server through a SOCKS4 or SOCKS5 proxy. Chilkat Java Downloads. Java Libs for Windows, Linux, Alpine...
Read more >Proxies and custom sockets - Rebex SFTP - Rebex.NET
To connect through SOCKET4, SOCKET4a or SOCKS5 proxy servers, set Sftp.Proxy properties before calling the Connect method. Use ProxyType property to specify ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For anyone else coming to this, there’s a working solution 🎉:
Yeah - it’s related. The example in #376 basically came out of what was discussed in #104. AsyncSSH also now supports specifying an external program to run to act as a proxy you can tunnel SSH requests over. However, that would be a lot less efficient than using aiosocks as shown in #376 for this use case.