Skip to content

SFTP sessions start in /tmp/coder.KnYnxH (instead of $HOME) #3620

Closed
@mafredri

Description

@mafredri

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:

  1. Run os.Chdir in an early part of coder agent startup to change the default working directory by anything started by the agent
  2. Switch out sftp.Server for sftp.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 $HOME when using sftp

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiArea: HTTP API

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions