Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to use ssh to log into remote servers, and I have a ProxyCommand setup in ~/.ssh/config to use a proxy (setup through PuTTY to connect to a VPN). The ProxyCommand uses nc to connect through the proxy (as described in the answer to How can I use SSH with a SOCKS 5 proxy?), but nc doesn't seem to be able to resolve the hostname to an IP through /etc/hosts before sending it on to the proxy, and the proxy doesn't know how to resolve the hostname.

For instance:

$ cat /etc/hosts
127.0.0.1       localhost
12.34.56.78     hostname1
12.34.56.79     hostname2


$ cat ~/.ssh/config
ProxyCommand /usr/bin/nc -x 127.0.0.1:7777 %h %p

Note that port 7777 is configured as a dynamic port in PuTTY.

$ cat /etc/resolv.conf
lookup  file bind


$ cat /etc/nsswitch.conf
hosts:  files dns

If I use ssh user@12.34.56.78 then the connection succeeds, but if I use ssh user@hostname1 then hostname1 gets passed to the proxy instead of being resolved to 12.34.56.78 and the connection fails. Does anyone know of any configurations that need to be made to make netcat hostname resolution through /etc/hosts work in cygwin?

Thanks

share|improve this question
    
does anything need to be executed to load the changes I made to the configuration files? –  Rusty Lemur Oct 24 '12 at 19:55

1 Answer 1

is /etc/hosts correctly delimited with whatever line ending is required (CR or CRNL)?

does nc neglect/etc/hosts and look at %windir%\system32\drivers\etc\hosts by any chance?

share|improve this answer
    
Can you expand your answer? This site is also for non-professionals, and we discourage small, short answers –  Canadian Luke Oct 24 '12 at 21:13
    
I believe /etc/hosts is correctly delimited with the UNIX line feed only (no carriage return). And I copied the file from the Windows location to Cygwin's /etc/hosts. After copying it I ran sed -i 's/\r//g' to remove any instances of carriage returns. –  Rusty Lemur Oct 24 '12 at 21:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.