Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sftp server set custom root path #509

Closed
juliojmjc opened this issue May 28, 2022 · 5 comments
Closed

sftp server set custom root path #509

juliojmjc opened this issue May 28, 2022 · 5 comments

Comments

@juliojmjc
Copy link

Hello, exist some kind of function to set to each client the own root folder access?
like: user1 -> /home/user1, usern -> /home/usern

@puellanivis
Copy link
Collaborator

It looks like we have not yet released a new version including this option but: #498 should do what you’re looking for.

@shanehooker
Copy link

It looks like we have not yet released a new version including this option but: #498 should do what you’re looking for.

Is #498 merged to master? I am also wanting to provide a landing path for an sftp client. I was looking for a function that provided the ability to run 'sftp-server -d [myLandingPath]'

@drakkan
Copy link
Collaborator

drakkan commented Sep 22, 2022

Hi,

#498 is included in v1.13.5

@drakkan drakkan closed this as completed Sep 22, 2022
@shanehooker
Copy link

shanehooker commented Sep 22, 2022 via email

@puellanivis
Copy link
Collaborator

Using the sftp.WithStartDirectory() does not guarantee that this path actually exists. Clients are expected to maintain their own state about what remote directory is the current working directory on the client side. If the server tells it that it is in /supercalifragilisticexpialidocious then the client will believe the server, even if that path does not exist. It will then make requests as if that were the current working directory, even if that path does not exist.

Again, the client thinking it is in the /foo/bar directory has no bearing on if that path actually exists. If the server says that’s the current working directory, the client has no choice but to assume it does. No checks are made prior to connection that the WithStartDirectory(path) exists within the request server.

In order to use this properly, you need to ensure that the /foo/bar directory passed into WithStartDirectory("/foo/bar") exists in the sftp.InMemHandler() before the client connects. The InMemoryHandler starts as an empty filesystem with only the root directory /. Since this is an in memory handler, chrooting it does not really make sense. No changes can be made to the underlying real filesystems, as it is entirely in memory, and lost at service restart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants