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

where do you set the user pass? #17

Open
x011 opened this issue Jun 21, 2020 · 2 comments
Open

where do you set the user pass? #17

x011 opened this issue Jun 21, 2020 · 2 comments

Comments

@x011
Copy link

x011 commented Jun 21, 2020

How do you set the login user and pass?

@zemin-piao
Copy link

By default it bypasses the check for login user+pass.

This can be changed by changing the code here:

class StubServer(ServerInterface):
    def check_auth_password(self, username, password):
        # all are allowed
        return AUTH_SUCCESSFUL

@dsoprea
Copy link

dsoprea commented Dec 15, 2023

Doesn't seem to work. I'm using this to host the server:

conn, addr = server_socket.accept()

transport = paramiko.Transport(conn)
transport.add_server_key(_STATIC_KEY)

transport.set_subsystem_handler(
    'sftp',
    paramiko.SFTPServer,
    StubSFTPServer)

server = sftpserver.stub_sftp.StubServer()
transport.start_server(server=server)

channel = transport.accept()

# Block until connection terminates
while transport.is_active():
    time.sleep(1)

..where this is sftpserver.stub_sftp.StubServer:

class StubServer (ServerInterface):
    def check_auth_password(self, username, password):
        # all are allowed
        return AUTH_SUCCESSFUL
        
    def check_auth_publickey(self, username, key):
        # all are allowed
        return AUTH_SUCCESSFUL
        
    def check_channel_request(self, kind, chanid):
        return OPEN_SUCCEEDED

    def get_allowed_auths(self, username):
        """List availble auth mechanisms."""
        return "password,publickey"

Yet, when I don't set a key into the client, I always get an authentication failure:

  File "/home/dustin/.pyenv/versions/workflow_application/lib/python3.8/site-packages/paramiko/transport.py", line 1414, in connect
    self.auth_password(username, password)
  File "/home/dustin/.pyenv/versions/workflow_application/lib/python3.8/site-packages/paramiko/transport.py", line 1587, in auth_password
    return self.auth_handler.wait_for_response(my_event)
  File "/home/dustin/.pyenv/versions/workflow_application/lib/python3.8/site-packages/paramiko/auth_handler.py", line 263, in wait_for_response
    raise e
paramiko.ssh_exception.AuthenticationException: Authentication failed.

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

3 participants