我正在尝试通过SSH连接到我的VM并执行了git pull
我有
import paramiko
import time
import sys
import os
import pdb
# Note
# sudo pip install --user paramiko
ip = "111.111.111.111"
un = "root"
pw = "abc"
def ssh_con (ip, un, pw):
global ssh
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, username=un, password=pw)
def cmd_io (command):
global ssh_cmd
ssh_cmd.send("%s \n" %command)
time.sleep(1)
output = ssh_cmd.recv(10000).decode("utf-8")
print (output)
ssh_con(ip,un,pw)
ssh_cmd = ssh.invoke_shell()
print ("SSH CONNECTION ESTABLISHED TO %s" % ip)
cmd_io("git pull")
time.sleep(2)
cmd_io(pw)
我一直在
git pull
Enter passphrase for key '/root/.ssh/id_rsa':
Enter passphrase for key '/root/.ssh/id_rsa':
答案 0 :(得分:1)
看起来您的SSH Rsa密钥对已经在111.111.111.111上设置了root的密码短语。您可以使用以下命令重新创建ssh rsa密钥:
ssh-keygen -t rsa
然后将密码留空。