SSH into VM and run "git pull" using Paramiko - Python
<p>I'm trying to SSH into my VM and did perform a <code>git pull</code> </p>

<ul>
<li>the SSH seems to be working fine </li>
<li>the git pull seem to be executed</li>
<li>but when I provide password, it doesn't seem to take it </li>
<li>Am I missing something ? </li>
</ul>

<hr>

<p>I have </p>

<pre><code>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)
</code></pre>

<hr>

<p>I kept getting </p>

<pre><code>git pull 
Enter passphrase for key '/root/.ssh/id_rsa': 

Enter passphrase for key '/root/.ssh/id_rsa': 
</code></pre>

<p>It looks like your SSH Rsa Key pair  has been setup up with a pass phrase for root on 111.111.111.111. You can recreate the ssh rsa key with:</p>

<pre><code>ssh-keygen -t rsa
</code></pre>

<p>and just leave pass phrase blank.</p>

python git ssh paramiko