具有两个用户名的Paramiko auth(Dell交换机)

2024-05-19 23:02:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用python over SSH对旧的Dell交换机进行大规模更新。他们两次提示输入用户名。在

login as:

User Name:secureuser
Password:

第一个提示实际上并不重要。我刚按回车键。问题是帕拉米科不会授权,因为这一点。我想正是因为这个帕拉米科相信它只是公钥认证。我不知道如何告诉帕拉米科在授权前发送回车。我用“\n”尝试过这个方法,但我没有成功(万岁玛丽):

^{pr2}$

使用telnet这不是问题。宋承宪更狡猾。在

Traceback (most recent call last):
  File "C:\Users\newbie\workspace\Misc python scripts\SSH-IPs-from-file.py", line 80, in <module>
    main()    
  File "C:\Users\newbie\workspace\Misc python scripts\SSH-IPs-from-file.py", line 73, in main
    tel.sshDell()
  File "C:\Users\newbie\workspace\Misc python scripts\SSH-IPs-from-file.py", line 57, in sshDell
    ssh.connect(eachhost, username= "\n" + username, password=password, look_for_keys=False)   
  File "C:\Python27\lib\site-packages\paramiko\client.py", line 381, in connect
    look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host)
  File "C:\Python27\lib\site-packages\paramiko\client.py", line 622, in _auth
    raise saved_exception
paramiko.ssh_exception.BadAuthenticationType: ('Bad authentication type', [u'publickey']) (allowed_types=[u'publickey'])

这里是SSH调试。请注意,在第二个用户名提示之前,我按了一下enter键:

user@ubuntu:/ansible$ ssh -vvv admin@10.58.7.2
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 10.58.7.2 [10.58.7.2] port 22.
debug1: Connection established.
debug1: identity file /home/cbabcock/.ssh/id_rsa type -1
debug1: identity file /home/cbabcock/.ssh/id_rsa-cert type -1
debug1: identity file /home/cbabcock/.ssh/id_dsa type -1
debug1: identity file /home/cbabcock/.ssh/id_dsa-cert type -1
debug1: identity file /home/cbabcock/.ssh/id_ecdsa type -1
debug1: identity file /home/cbabcock/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/cbabcock/.ssh/id_ed25519 type -1
debug1: identity file /home/cbabcock/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8
debug1: Remote protocol version 2.0, remote software version OpenSSH_3.4p1.RL
debug1: match: OpenSSH_3.4p1.RL pat OpenSSH_3.* compat 0x01000000
debug2: fd 3 setting O_NONBLOCK
debug3: load_hostkeys: loading entries for host "10.58.7.2" from file "/home/cbabcock/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/cbabcock/.ssh/known_hosts:6
debug3: load_hostkeys: loaded 1 keys
debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-rsa
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-dss-cert-v00@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,arcfour,aes192-cbc,aes256-cbc
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,arcfour,aes192-cbc,aes256-cbc
debug2: kex_parse_kexinit: hmac-sha1,hmac-md5
debug2: kex_parse_kexinit: hmac-sha1,hmac-md5
debug2: kex_parse_kexinit: none
debug2: kex_parse_kexinit: none
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_setup: setup hmac-md5
debug1: kex: server->client aes128-cbc hmac-md5 none
debug2: mac_setup: setup hmac-md5
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: bits set: 1044/2049
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 8e:b5:bf:04:06:c2:b8:10:30:b8:5e:49:2d:09:a5:e3
debug3: load_hostkeys: loading entries for host "10.58.7.2" from file "/home/cbabcock/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/cbabcock/.ssh/known_hosts:6
debug3: load_hostkeys: loaded 1 keys
debug1: Host '10.58.7.2' is known and matches the RSA host key.
debug1: Found key in /home/cbabcock/.ssh/known_hosts:6
debug2: bits set: 996/2049
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/cbabcock/.ssh/id_rsa ((nil)),
debug2: key: /home/cbabcock/.ssh/id_dsa ((nil)),
debug2: key: /home/cbabcock/.ssh/id_ecdsa ((nil)),
debug2: key: /home/cbabcock/.ssh/id_ed25519 ((nil)),
debug1: Authentication succeeded (none).
Authenticated to 10.58.7.2 ([10.58.7.2]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Entering interactive session.
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: packet_set_tos: set IP_TOS 0x10
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug1: Sending environment.
debug3: Ignored env XDG_SESSION_ID
debug3: Ignored env TERM
debug3: Ignored env SHELL
debug3: Ignored env SSH_CLIENT
debug3: Ignored env OLDPWD
debug3: Ignored env SSH_TTY
debug3: Ignored env USER
debug3: Ignored env LS_COLORS
debug3: Ignored env MAIL
debug3: Ignored env PATH
debug3: Ignored env PWD
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug3: Ignored env SHLVL
debug3: Ignored env HOME
debug3: Ignored env LOGNAME
debug3: Ignored env SSH_CONNECTION
debug3: Ignored env LESSOPEN
debug3: Ignored env XDG_RUNTIME_DIR
debug3: Ignored env LESSCLOSE
debug3: Ignored env _
debug2: channel 0: request shell confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 256 rmax 128
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0


User Name:
debug2: channel 0: rcvd adjust 1

User Name:adebug2: channel 0: rcvd adjust 1
ddebug2: channel 0: rcvd adjust 1
debug2: channel 0: rcvd adjust 1
midebug2: channel 0: rcvd adjust 1
debug2: channel 0: rcvd adjust 1
n
Password:debug2: channel 0: rcvd adjust 1
*debug2: channel 0: rcvd adjust 8
*******

pineh-sw1> debug2: channel 0: rcvd adjust 1
edebug2: channel 0: rcvd adjust 1
xdebug2: channel 0: rcvd adjust 1
idebug2: channel 0: rcvd adjust 1
tdebug2: channel 0: rcvd adjust 1

debug2: channel 0: rcvd close
debug2: channel 0: output open -> drain
debug2: channel 0: close_read
debug2: channel 0: input open -> closed
debug3: channel 0: will not send data after close
debug3: channel 0: will not send data after close
debug2: channel 0: obuf empty
debug2: channel 0: close_write
debug2: channel 0: output drain -> closed
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t4 r1 i3/0 o3/0 fd -1/-1 cc -1)

Connection to 10.58.7.2 closed.
Transferred: sent 3320, received 2984 bytes, in 13.8 seconds
Bytes per second: sent 240.3, received 216.0
debug1: Exit status -1
user@ubuntu:/ansible$

Tags: envcomparsechannelhmacsshcbcopenssh