代码下面的几天没问题,但是今天开始遇到下面的错误。生成新密钥后,也面临以下错误。可以请一些建议。
on-prem to on-prem - Connection successfull
on-prem to aws - facing below error
代码
import paramiko
import os
ssh_remote =paramiko.SSHClient()
ssh_remote.set_missing_host_key_policy(paramiko.AutoAddPolicy())
privatekeyfile = os.path.expanduser('/home/test/.ssh/id_rsa')
mykey = paramiko.RSAKey.from_private_key_file(privatekeyfile, password='test1234')
ssh_remote.connect('10.10.10.10', username = 'test', pkey = mykey)
hostin, hostout, hosterr = ssh_remote.exec_command("hostname")
source = hostout.read().decode().splitlines()
error = hosterr.read().decode().splitlines()
print 'source = ',source
print 'error = ',error
错误
source = []
error = [u'WARNING: Your password has expired.', u'Password change required but no TTY available.']
版本
Python version - 2.7.15
Paramiko version - 2.4.1
OpenSSh version - OpenSSH_5.3p1
用于生成密钥的命令
ssh-keygen -t rsa
试图手动连接
ssh test@10.10.10.10
Enter passphrase for key '/home/test/.ssh/id_rsa':
You are required to change your password immediately
WARNING: Your password has expired.
You must change your password now and login again!
Changing password for user test.
Changing password for test
(current) password:
Enter new password:
Confirm new password:
passwd: Authentication token manipulation error
Connection to 10.10.10.10 closed.