Can I connect to ssh client using proxy server in between? #1805

Open
sagarnigade opened this Issue Oct 22, 2013 · 2 comments

Comments

Projects
None yet
2 participants

I didn't found any documentation about this. please let me know any example of this how can use boto. Instead of directly connection to sshclient I will connet to proxy server and then redirect it to remote host.Is it possible?

I have tried below approach: in Boto\manage\cmdshell.py I have made below change

while retry < 5:
            try:print "connecting ssh client"
                proxy = paramiko.ProxyCommand('connect-proxy -S my_proxy_IP:8080')      
                self._ssh_client.connect(self.server.hostname,
                                         username=self.uname,
                                         pkey=self._pkey,sock=proxy)
which is giving me File "C:\Python27\lib\site-packages\paramiko\transport.py", line 465, in start_client raise e paramiko.SSHException: Error reading SSH protocol banner

I referered this link here in stackoverflow Paramiko Error: Error reading SSH protocol banner where they are saying

This issue didn't lie with Paramiko, Fabric or the SSH daemon. It was simply a firewall configuration in ISPs internal network. For some reason, they don't allow communication between different subnets of theirs. We couldn't really fix the firewall configuration so instead we switched all our IPs to be on the same subnet.

but in my case host is amazon instance what should I do in that case?

I am trying this becuase my client is not able to connect to host as normally boto connect with sshclient directly.
but using using Putty or openssh in connection with corkscrew he is able to connect.

This is urgent. Please let me know possible solution that I should try?

Owner

danielgtaylor commented Oct 24, 2013

I am not sure if that is possible. How can I set this up for myself to test?

@ghost

ghost commented Aug 17, 2015

I have the same problem.

With ssh_config file

more ssh_config
Host *
ProxyCommand connect.exe -4 -d -S proxy:1080 %h %p
ssh user@host
OK

but with paramiko:
def _login(self, username, password):
try:
Comando='connect.exe -4 -d -S proxy:1080 %h %p '
proxy = paramiko.ProxyCommand(Comando)
self.client.connect(self.config.host, self.config.port, username,
password, look_for_keys=False, allow_agent=False,
timeout=float(self.config.timeout),sock=proxy)
except paramiko.AuthenticationException:
raise SSHClientException

return:

DEB [20150817-15:41:03.664] thr=1 paramiko.transport: starting thread (client mode): 0x3011f10L
ERR [20150817-15:41:03.665] thr=1 paramiko.transport: Exception: Error reading SSH protocol banner(10038, 'Se intent\xf3 realizar una operaci\xf3n en un elemento que no es un socket')
ERR [20150817-15:41:03.667] thr=1 paramiko.transport: Traceback (most recent call last):
ERR [20150817-15:41:03.667] thr=1 paramiko.transport: File "C:\Python26\lib\site-packages\paramiko\transport.py", line 1584, in run
ERR [20150817-15:41:03.667] thr=1 paramiko.transport: self._check_banner()
ERR [20150817-15:41:03.667] thr=1 paramiko.transport: File "C:\Python26\lib\site-packages\paramiko\transport.py", line 1711, in _check_banner
ERR [20150817-15:41:03.667] thr=1 paramiko.transport: raise SSHException('Error reading SSH protocol banner' + str(e))
ERR [20150817-15:41:03.667] thr=1 paramiko.transport: SSHException: Error reading SSH protocol banner(10038, 'Se intent\xf3 realizar una operaci\xf3n en un elemento que no es un socket')
ERR [20150817-15:41:03.667] thr=1 paramiko.transport:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment