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

RuntimeError: Authentication failed, try to provide password #272

Closed
scott-5 opened this issue Nov 15, 2022 · 4 comments
Closed

RuntimeError: Authentication failed, try to provide password #272

scott-5 opened this issue Nov 15, 2022 · 4 comments
Labels

Comments

@scott-5
Copy link

scott-5 commented Nov 15, 2022

We have two batch job system (Torque and LSF). This example is run by RSA type key ( id_rsa ) for logging. But results are as below:
In Torque, RuntimeError: Authentication failed, try to provide password
In LSF, it works.

So I try connecting by paramiko.

import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("Torque ip", username="user", key_filename="/home/user/.ssh/id_rsa")
ssh.connect("LSF ip", username="user", key_filename="/home/user/.ssh/id_rsa")

In Torque, ValueError: q must be exactly 160, 224, or 256 bits long paramiko
In LSF, it works.

@njzjz
Copy link
Member

njzjz commented Nov 15, 2022

What is the output of ssh -vvv user@Torque ip -i /home/user/.ssh/id_rsa?

@scott-5
Copy link
Author

scott-5 commented Nov 17, 2022

Connecting with ssh go right.

(base) wang@DESKTOP-8DSA6LQ[09:26:57 16 jupyter_stuff]$ ssh -vvv wang@56.213.112.36 -i /home/wang/.ssh/id_rsa
OpenSSH_8.2p1 Ubuntu-4ubuntu0.2, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /home/wang/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname 56.213.112.36 is address
debug2: ssh_connect_direct
debug1: Connecting to 56.213.112.36 [56.213.112.36] port 22.
debug1: Connection established.
debug1: identity file /home/wang/.ssh/id_rsa type 0
debug1: identity file /home/wang/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000002
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to 56.213.112.36:22 as 'wang'
debug3: hostkeys_foreach: reading file "/home/wang/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/wang/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from 56.213.112.36   
debug3: order_hostkeyalgs: prefer hostkeyalgs: rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c
debug2: host key algorithms: rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,sk-ssh-ed25519@openssh.com
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-rsa,ssh-dss
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: MACs ctos: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: MACs stoc: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: compression ctos: none,zlib@openssh.com
debug2: compression stoc: none,zlib@openssh.com
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: umac-64@openssh.com compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: umac-64@openssh.com compression: none
debug3: send packet: type 34
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<3072<8192) sent
debug3: receive packet: type 31
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug2: bits set: 1547/3072
debug3: send packet: type 32
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug3: receive packet: type 33
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:kytJf8dUuvATS2aSnSEfOwkK8u/eJ5TErBysDw+2vts
debug3: hostkeys_foreach: reading file "/home/wang/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/wang/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from 56.213.112.36
debug1: Host '56.213.112.36' is known and matches the RSA host key.
debug1: Found key in /home/wang/.ssh/known_hosts:1
debug2: bits set: 1581/3072
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey out after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey in after 4294967296 blocks
debug1: Will attempt key: /home/wang/.ssh/id_rsa RSA SHA256:DbuvW8UH43eq0N9ZIg4RuePWwRkjGDlPTHwx4ptEoJA explicit
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
debug3: preferred gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup gssapi-with-mic
debug3: remaining preferred: publickey,keyboard-interactive,password
debug3: authmethod_is_enabled gssapi-with-mic
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)


debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)


debug2: we did not send a packet, disable method
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/wang/.ssh/id_rsa RSA SHA256:DbuvW8UH43eq0N9ZIg4RuePWwRkjGDlPTHwx4ptEoJA explicit
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: /home/wang/.ssh/id_rsa RSA SHA256:DbuvW8UH43eq0N9ZIg4RuePWwRkjGDlPTHwx4ptEoJA explicit
debug3: sign_and_send_pubkey: RSA SHA256:DbuvW8UH43eq0N9ZIg4RuePWwRkjGDlPTHwx4ptEoJA
debug3: sign_and_send_pubkey: signing using ssh-rsa SHA256:DbuvW8UH43eq0N9ZIg4RuePWwRkjGDlPTHwx4ptEoJA
debug3: send packet: type 50
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).
Authenticated to 56.213.112.36 ([56.213.112.36]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting no-more-sessions@openssh.com
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
debug3: receive packet: type 91
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x10
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug3: send packet: type 98
debug1: Sending environment.
debug3: Ignored env SHELL
debug3: Ignored env CONDA_EXE
debug3: Ignored env _CE_M
debug3: Ignored env WSL_DISTRO_NAME
debug3: Ignored env WT_SESSION
debug3: Ignored env HISTTIMEFORMAT
debug3: Ignored env NAME
debug3: Ignored env PWD
debug3: Ignored env LOGNAME
debug3: Ignored env CONDA_PREFIX
debug3: Ignored env MOTD_SHOWN
debug3: Ignored env HOME
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env WSL_INTEROP
debug3: Ignored env LS_COLORS
debug3: Ignored env CONDA_PROMPT_MODIFIER
debug3: Ignored env LESSCLOSE
debug3: Ignored env TERM
debug3: Ignored env _CE_CONDA
debug3: Ignored env LESSOPEN
debug3: Ignored env USER
debug3: Ignored env CONDA_SHLVL
debug3: Ignored env SHLVL
debug3: Ignored env CONDA_PYTHON_EXE
debug3: Ignored env PS1
debug3: Ignored env CONDA_DEFAULT_ENV
debug3: Ignored env WSLENV
debug3: Ignored env XDG_DATA_DIRS
debug3: Ignored env PATH
debug3: Ignored env HOSTTYPE
debug3: Ignored env WT_PROFILE_ID
debug3: Ignored env OLDPWD
debug3: Ignored env _
debug2: channel 0: request shell confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0

Here is original error:

AuthenticationException                   Traceback (most recent call last)
File ~/anaconda3/envs/dflow/lib/python3.9/site-packages/dpdispatcher/ssh_context.py:151, in SSHSession._setup_ssh(self)
    150 try:
--> 151     ts.auth_publickey(self.username, key)
    152 except paramiko.ssh_exception.AuthenticationException as e:

File ~/anaconda3/envs/dflow/lib/python3.9/site-packages/paramiko/transport.py:1635, in Transport.auth_publickey(self, username, key, event)
   1634     return []
-> 1635 return self.auth_handler.wait_for_response(my_event)

File ~/anaconda3/envs/dflow/lib/python3.9/site-packages/paramiko/auth_handler.py:259, in AuthHandler.wait_for_response(self, event)
    258         return e.allowed_types
--> 259     raise e
    260 return []

AuthenticationException: Authentication failed.

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
Cell In [3], line 1
----> 1 machine = Machine.load_from_json('machine.json')
      2 resources = Resources.load_from_json('resources.json')
      4 task0 = Task.load_from_json('task.json')

File ~/anaconda3/envs/dflow/lib/python3.9/site-packages/dpdispatcher/machine.py:118, in Machine.load_from_json(cls, json_path)
    116 with open(json_path, 'r') as f:
    117     machine_dict = json.load(f)
--> 118 machine = cls.load_from_dict(machine_dict=machine_dict)
    119 return machine

File ~/anaconda3/envs/dflow/lib/python3.9/site-packages/dpdispatcher/machine.py:134, in Machine.load_from_dict(cls, machine_dict)
    131 machine_dict = base.normalize_value(machine_dict, trim_pattern="_*")
    132 base.check_value(machine_dict, strict=False)
--> 134 context = BaseContext.load_from_dict(machine_dict)
    135 machine = machine_class(context=context)
    136 return machine

File ~/anaconda3/envs/dflow/lib/python3.9/site-packages/dpdispatcher/base_context.py:41, in BaseContext.load_from_dict(cls, context_dict)
     39     dlog.error(f"KeyError:context_type; context_type:{context_type}; cls.subclasses_dict:{cls.subclasses_dict}")
     40     raise e
---> 41 context = context_class.load_from_dict(context_dict)
     42 return context

File ~/anaconda3/envs/dflow/lib/python3.9/site-packages/dpdispatcher/ssh_context.py:350, in SSHContext.load_from_dict(cls, context_dict)
    347 remote_profile = context_dict['remote_profile']
    348 clean_asynchronously = context_dict.get('clean_asynchronously', False)
--> 350 ssh_context = cls(
    351     local_root=local_root,
    352     remote_root=remote_root,
    353     remote_profile=remote_profile,
    354     clean_asynchronously=clean_asynchronously
    355 )
    356 # local_root = jdata['local_root']
    357 # ssh_session = SSHSession(**input)
    358 # ssh_context = SSHContext(
   (...)
    361 #     clean_asynchronously=jdata.get('clean_asynchronously', False),
    362 #     )
    363 return ssh_context

File ~/anaconda3/envs/dflow/lib/python3.9/site-packages/dpdispatcher/ssh_context.py:323, in SSHContext.__init__(self, local_root, remote_root, remote_profile, clean_asynchronously, *args, **kwargs)
    317 self.clean_asynchronously = clean_asynchronously
    318 # self.job_uuid = job_uuid
    319 # if job_uuid:
    320 #    self.job_uuid=job_uuid
    321 # else:
    322 #    self.job_uuid = str(uuid.uuid4())
--> 323 self.ssh_session = SSHSession(**remote_profile)
    324 # self.temp_remote_root = os.path.join(self.ssh_session.get_session_root())
    325 self.ssh_session.ensure_alive()

File ~/anaconda3/envs/dflow/lib/python3.9/site-packages/dpdispatcher/ssh_context.py:44, in SSHSession.__init__(self, hostname, username, password, port, key_filename, passphrase, timeout, totp_secret, tar_compress)
     42 self.ssh = None
     43 self.tar_compress = tar_compress
---> 44 self._setup_ssh()

File ~/anaconda3/envs/dflow/lib/python3.9/site-packages/dpdispatcher/utils.py:162, in retry.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
    160 while max_retry is None or current_retry < max_retry:
    161     try:
--> 162         return func(*args, **kwargs)
    163     except catch_exception as e:
    164         errors.append(e)

File ~/anaconda3/envs/dflow/lib/python3.9/site-packages/dpdispatcher/ssh_context.py:168, in SSHSession._setup_ssh(self)
    166     ts.auth_password(self.username, self.password)
    167 elif key_error is not None:
--> 168     raise RuntimeError("Authentication failed, try to provide password") from key_error
    169 else:
    170     raise RuntimeError("Please provide at least one form of authentication")

RuntimeError: Authentication failed, try to provide password

@njzjz
Copy link
Member

njzjz commented Nov 17, 2022

It might be paramiko/paramiko#1961, which won't be fixed.

@njzjz njzjz added the wontfix This will not be worked on label Nov 17, 2022
@njzjz njzjz added upstream and removed wontfix This will not be worked on labels Oct 18, 2023
@njzjz
Copy link
Member

njzjz commented Oct 18, 2023

I found the issue has been fixed by paramiko. See paramiko/paramiko@3ee4fb7

@njzjz njzjz closed this as completed Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants