need wrapper for ssh/scp

John Mitchell johnm at magnet.com
Wed Mar 29 12:28:58 EST 2000


On Wed, 29 Mar 2000, Thomas Wouters wrote:

> Does anyone have a wrapper or example code that will allow me to use ssh
> and scp in a python script. Normally you would use some form of popen, but
> I can't seem to feed ssh/scp a passphrase.

do you really need to give it a passphrase?  Depending on your security
requirements, you can just copy ssh's keys around w/o using passwords.

To do this, let's say your remote machine is named 'twaddle', remote user
'fiji', and you've already run ssh-keygen locally:

   % cat ~/.ssh/identity.pub | ssh fiji at twaddle \
	'mkdir .ssh ; chmod 700 .ssh ; cat >>.ssh/authorized-keys'

You have to type your password.  Next, test the connection:

   % ssh fiji at twaddle ls

If it works, with no password, you're home free.  Go take a look at how to
add 'fiji' to your ~/.ssh/config file and all will be well.

I use ssh several times *an hour*.  Good stuff!


- j






More information about the Python-list mailing list