pkg / sftp

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

two sftp proxy questions #476

Closed aiderzcx closed 2 years ago

aiderzcx commented 2 years ago

i use sftp proxy, stream like this: user ----> sftp.Request Server ---> sftp.Client ---> host

1: Client.ReadDir discard longname, this use for command ls -l, how can i send longname to user? file: client.go, line: 238 filename, data = unmarshalString(data) _, data = unmarshalString(data) // discard longname
var attr *FileStat 2: user use cd command, i want to change user's pwd path, how can i do it? example: user path is "/", he can see root@192.168.1.1 (host name), use cd root@192.168.1.1 , he pwd path is /root@192.168.1.1, i want change user pwd path is /root, user home path in 192.168.1.1

puellanivis commented 2 years ago
  1. There is currently no way to pass along this longname in any way from sftp.Client to a caller. You would have to generate the longname yourself. This is something we might be able to expose through an expansion interface, but the SFTP specs are really adamant about not depending on this output. One should be using the properties of the file through Stat, Lstat, or Fstat.

  2. It is unclear at which point of this process you want to enable the cd path. The underlying sftp protocol does not contain any notion of a “working directory” (pwd = Print Working Directory), so paths between client and server have to be handled through their absolute path. It is up to the client to maintain this concept of “working directory” themselves. As of now sftp.Client does not support any sort of working directory functionality.

aiderzcx commented 2 years ago

clear, thanks