File Transfer (SFTP)¶
SSHClient speaks SFTP version 3 over the sftp subsystem. Each operation
opens an SFTP channel, performs the transfer, and closes the channel; the
SSH connection stays up throughout.
Relative remote paths are relative to the remote user's home directory (that is where OpenSSH's SFTP server starts). Paths and filenames are UTF-8 end to end.
Downloading — GetFile¶
r←c.GetFile '/var/log/app.log' '/tmp/app.log' ⍝ (Remote Local)
r←c.GetFile 'report.pdf' ⍝ local name = basename
r.Data ⍝ the local path written
The transfer is binary-exact; existing local files are overwritten. On
failure (rc ¯1) no partial local file is left behind for a missing
remote file.
Uploading — PutFile¶
r←c.PutFile '/tmp/data.csv' 'uploads/data.csv' ⍝ (Local Remote)
r←c.PutFile 'data.csv' ⍝ remote name = basename
The remote file is created (or truncated) and written in 30,000-byte chunks. A missing local file is reported before anything touches the server.
Listing — ListDir¶
Each entry namespace has name, longname (the ls -l-style line), and
the numeric attributes size, uid, gid, permissions, atime,
mtime. The . and .. entries are included, as the server sends them.
Attributes — Stat¶
permissions is the full POSIX mode word (e.g. 33188 = regular file,
0o644); mtime/atime are Unix timestamps. Fields the server does not
send are 0.
Errors¶
SFTP failures come back as rc ¯1 with the server's own message:
An SFTP error never kills the SSH connection — the same client can carry on with further Exec or SFTP calls.