Scp with subprocess python with a private key
<p>How do i get this scp command converted for python subprocess.</p>

<pre><code> scp -i /home/ramesh7128/Downloads/&lt;private_key&gt;.pem /home/ramesh7128/Downloads/testing_transfer.py &lt;remote_add&gt;:&lt;remote_file_path&gt;
</code></pre>

<p>esp the part to include the private key path is where i am having issues. </p>

<p>Make sure you're including the user on the remote machine and that you've formatted things correctly:</p>

<pre><code>scp -i /home/ramesh7128/Downloads/&lt;private_key&gt;.pem /home/ramesh7128/Downloads/testing_transfer.py &lt;remote_user&gt;@&lt;remote_add&gt;:&lt;remote_file_path&gt;
scp -i private_key.pem /path/to/the/local/file root@server.com:/path/to/the/remote/file
</code></pre>

<p>EDIT: (from comments)</p>

<pre><code>subprocess.Popen(["scp", "-i", "path/to/private_key.pem", myfile, destination]) 
</code></pre>

<p>This syntax lets Popen know about the <code>-i</code> option.</p>

python django subprocess scp