pkg / sftp

SFTP support for the go.crypto/ssh package
BSD 2-Clause "Simplified" License
1.5k stars 379 forks source link

missing port in address #514

Closed liuzh825 closed 2 years ago

liuzh825 commented 2 years ago

If it is the ftp protocol, address: ftp:XXX.com, ssh dial will return an error: missing port in address Do we support this case?

drakkan commented 2 years ago

Hi,

ssh.Dial is defined in crypto/ssh and not in this package. In Go network methods generally the address are expected as "host:port". I think there is nothing we can do in this package, you have to use hostname:22 as address

puellanivis commented 2 years ago

Also, this is a common misconception but really the only thing SFTP and FTP share in common are the name. FTP is a very different protocol from SFTP, and is fundamentally not compatible with the SFTP protocol. SFTP is not simply FTP tunneled through SSH.

As a further even more nitpicky statement, the form ftp:example.com is not a valid FTP URL, as the example.com is an authority and not a path, and thus requires the // in the URL. The appropriate URL would be ftp://example.com.

Some URL parsers are known to accept strings as ports so you could do something like sftp://example.com:ssh however this is actually contrary to the standard and port, when included, must be all digits. Go at around 1.14 started requiring ports to be all digits.

I understand that a lot of this is super nitpicky, but standards often have to treated so strictly, lest you introduce incompatibilities between implementations, potentially even between two versions of the same codebase.

liuzh825 commented 2 years ago

Thanks