Let SFTP server figure out remote users home directories#24254
Let SFTP server figure out remote users home directories#24254capnspacehook merged 1 commit intomasterfrom
Conversation
211fb55 to
2a44ee5
Compare
There was a problem hiding this comment.
Why a new channel for this?
The SSH protocol supports sending requests within a channel and over a global channel. We use that approach in other places where we need to get a string back (like version information).
https://github.com/gravitational/teleport/blob/master/lib/reversetunnel/srv.go#L1242
https://github.com/gravitational/teleport/blob/master/lib/reversetunnel/agent.go#L461
That feels like a better fit than creating a whole new channel for a string. What am I missing?
|
What does opensshd sftp do when connecting to openssh sshd, to resolve +1 for using a global request rather than opening a channel. It might make even more sense as a request local to the sftp subsystem channel, but sadly those can't carry a payload back so you'd need to either always blindly send it from the server side (and just wait with a timeout on the client side) or do some awkward back and forth with channel requests that are technically unrelated, and for a long time we've just been killing the channel whenever the server side received an unknown channel request (yay for extensibility, huh) so we can't really extend that part of the protocol until that's fixed and we pass a couple of major versions. |
2a44ee5 to
b59258e
Compare
b59258e to
d49a703
Compare
|
@russjones @espadolini thank you both for the questions and feedback, you both made me realize this was not an optimal solution at all. After reading the SFTP spec again I realized there's a much simpler solution, let the server figure out the correct path instead. |
d49a703 to
6fa37ff
Compare
Previously a Teleport client using SFTP would resolve remote host user home directories by making a subsystem request to a Teleport server which would return the home directory. The problem was the subsystem request counted as an open session, which could make the SFTP file transfer fail. This was frustrating and didn't make much sense, but after reading the SFTP specification again I realized that SFTP servers are to handle relative paths by assuming they start at the user's home directory. So let the server figure out the correct path and remove any tilde prefixes from remote paths.
6fa37ff to
d8f1843
Compare
|
Friendly ping @xacrimon |
|
@capnspacehook Can you backport this to branch/v12 as soon as you can please? |
In #24254 expansion of tilde prefixes(i.e. `tsh scp CHANGELOG.md root@host:~foo/`) was explicitly denied. However, because the error returned to the user is a trace.BadParameter error the reauthentication logic kicks in and attempts to resolve the issue with fresh credentials. This resulted in a weird UX and burried the underlying error in a wall of text. In order to make it very apparent to tusers that this is not a supported case these errors are now wrapped in a NonRetryableError so that users can better understand what is happening. Updates #22886.
In #24254 expansion of tilde prefixes(i.e. `tsh scp CHANGELOG.md root@host:~foo/`) was explicitly denied. However, because the error returned to the user is a trace.BadParameter error the reauthentication logic kicks in and attempts to resolve the issue with fresh credentials. This error is now caught and wrapped in a NonRetryableError to prevent the authentication logic from providing a weird UX. Updates #22886.
In #24254 expansion of tilde prefixes(i.e. `tsh scp CHANGELOG.md root@host:~foo/`) was explicitly denied. However, because the error returned to the user is a trace.BadParameter error the reauthentication logic kicks in and attempts to resolve the issue with fresh credentials. This error is now caught and wrapped in a NonRetryableError to prevent the authentication logic from providing a weird UX. Updates #22886.
In #24254 expansion of tilde prefixes(i.e. `tsh scp CHANGELOG.md root@host:~foo/`) was explicitly denied. However, because the error returned to the user is a trace.BadParameter error the reauthentication logic kicks in and attempts to resolve the issue with fresh credentials. This error is now caught and wrapped in a NonRetryableError to prevent the authentication logic from providing a weird UX. Updates #22886.
In #24254 expansion of tilde prefixes(i.e. `tsh scp CHANGELOG.md root@host:~foo/`) was explicitly denied. However, because the error returned to the user is a trace.BadParameter error the reauthentication logic kicks in and attempts to resolve the issue with fresh credentials. This error is now caught and wrapped in a NonRetryableError to prevent the authentication logic from providing a weird UX. Updates #22886.
In #24254 expansion of tilde prefixes(i.e. `tsh scp CHANGELOG.md root@host:~foo/`) was explicitly denied. However, because the error returned to the user is a trace.BadParameter error the reauthentication logic kicks in and attempts to resolve the issue with fresh credentials. This error is now caught and wrapped in a NonRetryableError to prevent the authentication logic from providing a weird UX. Updates #22886.
In #24254 expansion of tilde prefixes(i.e. `tsh scp CHANGELOG.md root@host:~foo/`) was explicitly denied. However, because the error returned to the user is a trace.BadParameter error the reauthentication logic kicks in and attempts to resolve the issue with fresh credentials. This error is now caught and wrapped in a NonRetryableError to prevent the authentication logic from providing a weird UX. Updates #22886.
In #24254 expansion of tilde prefixes(i.e. `tsh scp CHANGELOG.md root@host:~foo/`) was explicitly denied. However, because the error returned to the user is a trace.BadParameter error the reauthentication logic kicks in and attempts to resolve the issue with fresh credentials. This error is now caught and wrapped in a NonRetryableError to prevent the authentication logic from providing a weird UX. Updates #22886.
In #24254 expansion of tilde prefixes(i.e. `tsh scp CHANGELOG.md root@host:~foo/`) was explicitly denied. However, because the error returned to the user is a trace.BadParameter error the reauthentication logic kicks in and attempts to resolve the issue with fresh credentials. This error is now caught and wrapped in a NonRetryableError to prevent the authentication logic from providing a weird UX. Updates #22886.
In #24254 expansion of tilde prefixes(i.e. `tsh scp CHANGELOG.md root@host:~foo/`) was explicitly denied. However, because the error returned to the user is a trace.BadParameter error the reauthentication logic kicks in and attempts to resolve the issue with fresh credentials. This error is now caught and wrapped in a NonRetryableError to prevent the authentication logic from providing a weird UX. Updates #22886.
In #24254 expansion of tilde prefixes(i.e. `tsh scp CHANGELOG.md root@host:~foo/`) was explicitly denied. However, because the error returned to the user is a trace.BadParameter error the reauthentication logic kicks in and attempts to resolve the issue with fresh credentials. This error is now caught and wrapped in a NonRetryableError to prevent the authentication logic from providing a weird UX. Updates #22886.
In #24254 expansion of tilde prefixes(i.e. `tsh scp CHANGELOG.md root@host:~foo/`) was explicitly denied. However, because the error returned to the user is a trace.BadParameter error the reauthentication logic kicks in and attempts to resolve the issue with fresh credentials. This error is now caught and wrapped in a NonRetryableError to prevent the authentication logic from providing a weird UX. Updates #22886.
In #24254 expansion of tilde prefixes(i.e. `tsh scp CHANGELOG.md root@host:~foo/`) was explicitly denied. However, because the error returned to the user is a trace.BadParameter error the reauthentication logic kicks in and attempts to resolve the issue with fresh credentials. This error is now caught and wrapped in a NonRetryableError to prevent the authentication logic from providing a weird UX. Updates #22886.
…onal#51464) In gravitational#24254 expansion of tilde prefixes(i.e. `tsh scp CHANGELOG.md root@host:~foo/`) was explicitly denied. However, because the error returned to the user is a trace.BadParameter error the reauthentication logic kicks in and attempts to resolve the issue with fresh credentials. This error is now caught and wrapped in a NonRetryableError to prevent the authentication logic from providing a weird UX. Updates gravitational#22886.
Previously a Teleport client using SFTP would resolve remote host user
home directories by making a subsystem request to a Teleport server
which would return the home directory. The problem was the subsystem
request counted as an open session, which could make the SFTP file
transfer fail. This was frustrating and didn't make much sense, but
after reading the SFTP specification again I realized that SFTP servers
are to handle relative paths by assuming they start at the user's home
directory. So let the server figure out the correct path and remove any
tilde prefixes from remote paths.
Fixes #23593.