-1

Is there a way to set up a ChrootDirectory for a system only for SFTP and not for ssh?

i.e. if I wanted to ssh into a server and have root be a certain directory, but SFTP into the same server and have a different directory as root, is that possible? I have been trying to toggle /etc/ssh/sshd_config to make this work but it has not been successful yet. I do not have sudo access so I cannot add another user, so this would have to be on the same user.

  • Welcome to Stack Overflow! Please move your question to [su] (delete here, re-post there). It's [off-topic here](https://stackoverflow.com/help/on-topic). – Martin Prikryl Aug 13 '21 at 05:44

1 Answers1

0

To have an alternate working directory after logging in with sftp, the path can be appended with a colon. Replace remote-host with user@host or ssh config Host pattern.

sftp remote-host:relative/path

or

sftp remote-host:/absolute/path

For similar behavior with ssh, see this answer.

Cole Tierney
  • 9,571
  • 1
  • 27
  • 35