Closed
Labels
apiArea: HTTP API
Description
Since we are starting the coder agent in the tmpdir, SFTP sessions also start in that folder.
Arguably, the session should start in $HOME because this is my experience with OpenSSH and it's more useful when doing sftp followed by ls (list files) or doing something with home-relative paths.
sftp coder.work.main
Connected to coder.work.main.
sftp> pwd
Remote working directory: /tmp/coder.KnYnxH
There are (potentially) two ways to fix this:
- Run
os.Chdirin an early part ofcoder agentstartup to change the default working directory by anything started by the agent - Switch out
sftp.Serverforsftp.RequestServer(e.g.sftp.NewRequestServer(session, sftp.InMemHandler(), sftp.WithStartDirectory(os.Getenv("HOME"))))
Re: 2, I don't know if sftp.RequestServer can work as a drop-in replacement, the documentation is quite vague.
Definition of done
- The user lands in
$HOMEwhen usingsftp
Metadata
Metadata
Assignees
Labels
apiArea: HTTP API
Activity
kylecarbs commentedon Sep 23, 2022
I investigated this a bit... it's quite involved.
We'll have to implement file handlers ourselves since their implementation is in-memory only. See: https://github.com/pkg/sftp/blob/811ed177f06e87f233019bf6eb908c0c73095d15/request-example.go#L24
Apart from that, it seems like we could just swap it out.
fix: Start SFTP sessions in user home (working directory)
fix: Start SFTP sessions in user home (working directory)
fix: Start SFTP sessions in user home (working directory) (#4549)