tags:

views:

385

answers:

5

Assuming that I cannot run something like this with Fabric:

run("svn update --password 'password' .")

how's the proper way to pass to Fabric the password for the remote interactive command line?

The problem is that the repo is checked out as svn+ssh and I don't have a http/https/svn option

A: 

You might need to supply the user as well? If not, you may have better luck exporting your repo and making a tar of it (locally) to upload+deploy on the server. If you run the svn commands locally, you'll be able to get prompted for your username and/or password.

Alex Jillard
I've tried supplying the --username switch as well, without any luck.
hyperboreean
+1  A: 

We had a problem similar to this a while back and actually proposed a new feature for Fabric, but the developer we spoke to suggested this instead.

import getpass
password = getpass.getpass('Enter SVN Password: ')
run("svn update --password '%s'" % password)

This will prompt you for a password when the time comes for fabric to run this command.

I believe that will display your password in the fabric log, however, so a better option would be to get SVN to prompt you for the password and echo the password into it.

run('echo %s | svn update --password' % password)

I don't use SVN though, so I'm afraid I'm not sure if that is possible. I hope someone else can help there!

mac
As I stated above svn update --password doesn't work at all, since that options is for http/https only.
hyperboreean
What I am looking for is an automatic way of passing the password interactively.
hyperboreean
Well, echoing your commands into SVN might still be worth a go. You should be able to echo the password into the interactive prompt, but your mileage may vary.
mac
+1  A: 

My standard answer for automating interactive command lines is "use Expect", but you're using Python, so I will slightly refine that to "use Pexpect".

It might take a bit of thought to integrate Pexpect within Fabric, or perhaps you will just end up falling back to Pexpect alone for this particular case. But it's definitely the way I would go.

Zac Thompson
+4  A: 

Try SSHkey. It's allow you to connect to the server without password. In this case, you will have to setup a sshkey between your remote server and the repo.

At remote server: Generate key pair

 $ ssh-keygen -t dsa

Leave the passphase empty! This will gerenate 2 files

  • ~/.ssh/id_dsa (private key)
  • ~/.ssh/id_dsa.pub (public key)

Then, append the content in id_dsa.pub to ~/.ssh/authorized_keys at repo server.

Your remote server will be able to update the source tree without using password.

Bird
A: 

You should take a look at the Fabric's env documentation. There states that you should make something like this:

from fabric.api import env

env.user = 'your_user'
env.password = 'your_password'

Hope it helps!

mpeterson