-
Notifications
You must be signed in to change notification settings - Fork 153
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
Conflict between SSH and SFTP? #707
Comments
If you pass in Alternately, if you want more control over exactly which sessions are allowed and which handler to use on a case-by-case basis, you should leave these arguments unset and instead implement one or more of the callback methods |
Thanks for the response. I'm just a little confused, because in the API docs it reads:
My def session_requested(self) -> PromptToolkitSSHSession:
"""
Setup a session and associate the Django User object.
"""
session = PromptToolkitSSHSession(self.interact, enable_cpr=self.enable_cpr)
session.user = self.user
return session Since I need the I also tried adding the callback methods to the SSHServer class (returning True), but they didn't seem to get called. Thanks again for a great library. I know I'm just a couple steps away from grokking this part. |
The If you want to have your own SSHServer class, you can have its def handle_session(self, stdin, stdout, stderr):
# Add session processing here, referencing "self" to get at data in your SSHServer instance
def session_requested(self):
# Set up whatever custom state you need
return self.handle_session Keep in mind that session_requested() may be called multiple times, though. If you need to support multiple sessions each with unique custom state, you may need to add extra arguments to the handle_session class and use something like If you just need access to the username or some other SSH connection state, there are simpler ways to accomplish that. The easiest way is using def handle_client(process: asyncssh.SSHServerProcess) -> None:
username = process.get_extra_info('username')
process.stdout.write(f'Welcome to my SSH server, {username}!\n')
process.exit(0) Any other per-session state can be initialized after this process handler starts up. |
Using |
Thanks folks. Going to try this today. Good to know about the PromptToolkitSSHSession. TBH this SFTP feature isn't really a hard requirement I just thought it would be cool. |
I've run into a strange issue while attempting to implement SFTP support on top of a custom SSH interface. I've narrowed it down to this:
If I run as is, my custom shell works great. If I uncomment the
sftp_factory
, the SFTP function works fine — but then logins to the shell fail withshell request failed on channel 0
. From the server side, I see it authenticate the user, but then close the connection immediately after that:The SFTPServer code is really new to me, so I'm sure it's an issue on my end, but would appreciate a suggestion about where to start.
Thanks in advance,
-Phil
The text was updated successfully, but these errors were encountered: