Python 如何为Azure自动输入密码?
我想自动登录Azure系统以访问虚拟机。我运行以下代码:Python 如何为Azure自动输入密码?,python,automation,subprocess,passwords,Python,Automation,Subprocess,Passwords,我想自动登录Azure系统以访问虚拟机。我运行以下代码: process_1=subprocess.call(key.SSH_key+'|'+key.PASSKEY,shell=True)#登录到虚拟机 并收到以下文件: /bin/sh: key.PASSKEY: command not found azureuser@xx.xx.1x.1xx's password: 当它是key的输入时,它认为key.PASSKEY是另一个命令azureuser@xx.xx.1x.1xx用户密码:par
process_1=subprocess.call(key.SSH_key+'|'+key.PASSKEY,shell=True)#登录到虚拟机
并收到以下文件:
/bin/sh: key.PASSKEY: command not found
azureuser@xx.xx.1x.1xx's password:
当它是
key的输入时,它认为key.PASSKEY
是另一个命令azureuser@xx.xx.1x.1xx用户密码:
part。如何确保在运行此子流程命令时自动输入密钥.PASSKEY
作为密码?使用以下视频找到答案:
我做到了:
ch = pexpect.spawn(key.SSH_KEY)
ch.logfile = sys.stdout.buffer
ch.expect("azureuser@xx.xx.1x.1xx's password:")
ch.sendline(key.PASSKEY)
ch.expect("azureuser@vm")
ch.sendline('ls')