Remote address in SSH DialTCP must be IP address

103 views
Skip to first unread message

tgros...@extrahop.com

unread,
Jan 13, 2017, 12:59:39 PM1/13/17
to golang-nuts
In the crypto/ssh package, the DialTCP function requires that the remote address be presented as a TCPAddr. See https://github.com/golang/crypto/blob/master/ssh/tcpip.go#L324

This means the remote address must be an IP address and port combination, domain names are not possible. The specification (see https://tools.ietf.org/html/rfc4254#section-7.2) states that the remote "host to connect" "may be either a domain name or a numeric IP address".

Why was this decision/limitation made? If I need to use a domain name should I just copy the library and make the changes I need?

Dave Cheney

unread,
Jan 13, 2017, 3:09:35 PM1/13/17
to golang-nuts
I'm pretty sure you can use the Dial method above, DialTCP was added to avoid using the DNS server at the remote end (I think, it's been years)

Tony Grosinger

unread,
Jan 16, 2017, 10:36:27 PM1/16/17
to golang-nuts
That worked perfectly, thanks Dave.
Reply all
Reply to author
Forward
0 new messages