| Summary: | using "sftp root@[2001::16%eth0]", output error: Could not resolve hostname: Name or service not known | ||
|---|---|---|---|
| Product: | Portable OpenSSH | Reporter: | xuchunmei <xuchunmei> |
| Component: | sftp | Assignee: | Assigned to nobody <unassigned-bugs> |
| Status: | NEW --- | ||
| Severity: | normal | ||
| Priority: | P5 | ||
| Version: | 7.9p1 | ||
| Hardware: | ix86 | ||
| OS: | Linux | ||
when using sftp to connect ipv6 address without path, error happens like this: sftp root@[2001::16%eth0] ssh: Could not resolve hostname [2001::16%eth0]: Name or service not known Connection closed. Connection closed openssh version is: openssh-clients-7.8p1-3.fc29.x86_64 OS is fedora29 x86 i try to analyse the error output, when parse_user_host_path, colon funciton: char * colon(char *cp) { int flag = 0; if (*cp == ':') /* Leading colon is part of file name. */ return NULL; if (*cp == '[') flag = 1; for (; *cp; ++cp) { if (*cp == '@' && *(cp+1) == '[') flag = 1; if (*cp == ']' && *(cp+1) == ':' && flag) return (cp+1); if (*cp == ':' && !flag) return (cp); if (*cp == '/') return NULL; } return NULL; } after ']' there must be ':', otherwise return NULL, then the whole arg "root@[2001::16%eth0]" be treated as a plain hostname, host resolv failed. here is my solution: --- misc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/misc.c b/misc.c index bdc06fd..84dc451 100644 --- a/misc.c +++ b/misc.c @@ -557,6 +557,8 @@ colon(char *cp) flag = 1; if (*cp == ']' && *(cp+1) == ':' && flag) return (cp+1); + if (*cp == ']' && *(cp+1) == '\0' && flag) + return (cp+1); if (*cp == ':' && !flag) return (cp); if (*cp == '/') -- please check.