Thursday, October 1, 2015

linux - ssh tunnel - bind: Cannot assign requested address



Trying to create a socks (-D) ssh tunnel - Linux box to Linux box (both centos):



sshd running on remote side ok.




From local machine we do / see this:



ssh -D 1080 user@8.8.8.8.
user@8.8.8.8's password:
bind: Cannot assign requested address


(where 8.8.8.8 is really my server's IP and 'user' is my real username)




I am logged into the remote side in this terminal-window. I can verify that the local port was unused prior to this command, and then used by an ssh process, after the command, via:



netstat -lnp | grep 1080


So, unlike most googled-responses with this error, the problem would not seem to be the loopback interface assignment. If I try to use this tunnel with a mail client, the local-side permits the attempt (no 'proxy-failed' error), but no data / reply is returned.



On the remote side, I do have "PermitTunnel yes" in my sshd_config (though 'yes' should be the default, anyway).



Ideas or Clues?




Here is the relevant debug-output



OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *

....

debug1: Authentication succeeded (password).

debug1: Local connections to LOCALHOST:1080 forwarded to remote address socks:0
debug1: Local forwarding listening on 127.0.0.1 port 1080.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on ::1 port 1080.
bind: Cannot assign requested address
debug1: channel 1: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.utf8



Other clue: If I run a Virtual Box on the client running Windows, open a tunnel with putty in that box, that tunnel, to the same remote server, works.



Stranger Still" If I use Putty (for linux) running directly on the Linux Client, it does NOT work, even if the settings are an exact duplicate of the putty settings which DO WORK in Putty running on Windows in a Virtual Box on the same Client Machine?? There is something fishy ... still trying experiments to figure out what it is.


Answer



The close the loop here. The answer, in this case, was to force the ssh client to use ipv4. E.g.



ssh -4 -D 8081 user@8.8.8.8

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...