使用这个模块进行 scp 命令的时候, 因为 ip 不在已知的主机列表中, 所以有一个需要输入 yes/no 的动作,
The authenticity of host 'X.X.X.X (X.X.X.X)' can't be established.
ECDSA key fingerprint is SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.
ECDSA key fingerprint is MD5:67:2a:d8:dc:13:9XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.
Are you sure you want to continue connecting (yes/no)?
我的判断是: i = child.expect(['denied', 'yes/no', 'assword', '100%'], timeout=10)
但是每次这里的检测都过不去, 不知道为什么
pexpect.exceptions.TIMEOUT: Timeout exceeded.
<pexpect.pty_spawn.spawn object at 0x7f22d181ecd0>
command: /usr/bin/scp
args: ['/usr/bin/scp', '/root/.ssh/id_rsa.pub', '[email protected]:/root/.ssh/authorized_keys']
buffer (last 100 chars): ')? '
before (last 100 chars): ')? '
after: <class 'pexpect.exceptions.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 11859
child_fd: 5
closed: False
timeout: 30
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
searcher: searcher_re:
0: EOF