簡體   English   中英

現有 SSH session 返回 paramiko.ssh_exception.SSHException: No existing session after windows upgrade

[英]Existing SSH session returns paramiko.ssh_exception.SSHException: No existing session after windows upgrade

我遇到了 paramiko 的奇怪行為
這是我的代碼:

con = paramiko.SSHClient()
con.load_system_host_keys()
con.set_missing_host_key_policy(paramiko.AutoAddPolicy())
con.connect(ip_address, port=port, username=user, password=password, timeout=30)

它現在可以正常工作幾個月,但是,在我為我的遠程機器(我連接到的機器)執行 windows 升級后,我收到異常

paramiko.ssh_exception.SSHException: No existing session

我看到其他 SO 線程並嘗試在 windows 升級后做同樣的事情但是

con.connect(ip_address, port=port, username=user, password=password, timeout=30, allow_agent=False, look_for_keys=False)

每當我這樣做時,我都會收到paramiko.ssh_exception.AuthenticationException: Authentication failed.

paramiko 日志 + 回溯:

regular traceback 

paramiko.transport  transport.py:1873 starting thread (client mode): 0x49455610
paramiko.transport  transport.py:1873 Local version/idstring: SSH-2.0-paramiko_2.10.3
paramiko.transport  transport.py:1873 Remote version/idstring: SSH-2.0-OpenSSH_for_Windows_8.6
paramiko.transport  transport.py:1873 Connected (version 2.0, client OpenSSH_for_Windows_8.6)
paramiko.transport  transport.py:1873 === Key exchange possibilities ===
paramiko.transport  transport.py:1873 kex algos: 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
paramiko.transport  transport.py:1873 server key: rsa-sha2-512, rsa-sha2-256, ssh-rsa, ecdsa-sha2-nistp256, ssh-ed25519
paramiko.transport  transport.py:1873 client encrypt: chacha20-poly1305@openssh.com, aes128-ctr, aes192-ctr, aes256-ctr, aes128-gcm@openssh.com, aes256-gcm@openssh.com
paramiko.transport  transport.py:1873 server encrypt: chacha20-poly1305@openssh.com, aes128-ctr, aes192-ctr, aes256-ctr, aes128-gcm@openssh.com, aes256-gcm@openssh.com
paramiko.transport  transport.py:1873 client mac: 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
paramiko.transport  transport.py:1873 server mac: 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
paramiko.transport  transport.py:1873 client compress: none, zlib@openssh.com
paramiko.transport  transport.py:1873 server compress: none, zlib@openssh.com
paramiko.transport  transport.py:1873 client lang: <none>
paramiko.transport  transport.py:1873 server lang: <none>
paramiko.transport  transport.py:1873 kex follows: False
paramiko.transport  transport.py:1873 === Key exchange agreements ===
paramiko.transport  transport.py:1873 Kex: curve25519-sha256@libssh.org
paramiko.transport  transport.py:1873 HostKey: ssh-ed25519
paramiko.transport  transport.py:1873 Cipher: aes128-ctr
paramiko.transport  transport.py:1873 MAC: hmac-sha2-256
paramiko.transport  transport.py:1873 Compression: none
paramiko.transport  transport.py:1873 === End of kex handshake ===
paramiko.transport  transport.py:1873 kex engine KexCurve25519 specified hash_algo <built-in function openssl_sha256>
paramiko.transport  transport.py:1873 Switch to new keys ...
paramiko.transport  transport.py:1873 Adding ssh-ed25519 host key for ip_adress: b'bla' #edited
paramiko.transport  transport.py:1873 Got EXT_INFO: {'server-sig-algs': b'ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,webauthn-sk-ecdsa-sha2-nistp256@openssh.com'}
paramiko.transport  transport.py:1873 Trying discovered key b'bla' in C:\Users\user/.ssh/id_rsa #edited
paramiko.transport  transport.py:1873 userauth is OK
paramiko.transport  transport.py:1873 Finalizing pubkey algorithm for key of type 'ssh-rsa'
paramiko.transport  transport.py:1873 Our pubkey algorithm list: ['rsa-sha2-512', 'rsa-sha2-256', 'ssh-rsa']
paramiko.transport  transport.py:1873 Server-side algorithm list: ['ssh-ed25519', 'sk-ssh-ed25519@openssh.com', 'ssh-rsa', 'rsa-sha2-256', 'rsa-sha2-512', 'ssh-dss', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', 'ecdsa-sha2-nistp521', 'sk-ecdsa-sha2-nistp256@openssh.com', 'webauthn-sk-ecdsa-sha2-nistp256@openssh.com']
paramiko.transport  transport.py:1873 Agreed upon 'rsa-sha2-512' pubkey algorithm
paramiko.transport  transport.py:1873 EOF in transport thread

 File "C:\projects\automation\windowsapi\scp_client.py", line 17, in __init__
    self.__ssh_client.connect(ip_address, port=port, username=user, password=password, timeout=30)
  File "C:\Users\user\.virtualenvs\automation-_iNAktOj\lib\site-packages\paramiko\client.py", line 435, in connect
    self._auth(
  File "C:\Users\user\.virtualenvs\automation-_iNAktOj\lib\site-packages\paramiko\client.py", line 766, in _auth
    raise saved_exception
  File "C:\Users\user\.virtualenvs\automation-_iNAktOj\lib\site-packages\paramiko\client.py", line 753, in _auth
    self._transport.auth_password(username, password)
  File "C:\Users\user\.virtualenvs\automation-_iNAktOj\lib\site-packages\paramiko\transport.py", line 1552, in auth_password
    raise SSHException("No existing session")
paramiko.ssh_exception.SSHException: No existing session

並使用disabled_algorithms=dict(pubkeys=['rsa-sha2-256', 'rsa-sha2-512'])

transport.py:1873 kex engine KexCurve25519 specified hash_algo <built-in function openssl_sha256>
transport.py:1873 Switch to new keys ...
transport.py:1873 Got EXT_INFO: {'server-sig-algs': b'ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,webauthn-sk-ecdsa-sha2-nistp256@openssh.com'}
transport.py:1873 Trying discovered key b'0b11111111' in C:\Users\user/.ssh/id_rsa # edited
transport.py:1873 userauth is OK
transport.py:1873 Finalizing pubkey algorithm for key of type 'ssh-rsa'
transport.py:1873 Our pubkey algorithm list: ['ssh-rsa']
transport.py:1873 Server-side algorithm list: ['ssh-ed25519', 'sk-ssh-ed25519@openssh.com', 'ssh-rsa', 'rsa-sha2-256', 'rsa-sha2-512', 'ssh-dss', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', 'ecdsa-sha2-nistp521', 'sk-ecdsa-sha2-nistp256@openssh.com', 'webauthn-sk-ecdsa-sha2-nistp256@openssh.com']
transport.py:1873 Agreed upon 'ssh-rsa' pubkey algorithm
transport.py:1873 EOF in transport thread

我發現了問題,我在機器上有 2 個帳戶, Administrator和我們在機器創建期間創建的自定義用戶

os升級完成后,windows決定禁用我用過SCP的用戶

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM