Fabric asks for password even though I can SSH using credential

bcattle picture bcattle · Apr 11, 2012 · Viewed 10k times · Source

I'm having an odd problem while deploying a Django site using Fabric. I've configured two servers to use key files for login. I can SSH into both without a password. I can run fab on one correctly,

$ fab live pull
[mysite.com] Executing task 'pull'
[mysite.com] run: test -d proj
[mysite.com] run: test -d proj/.git
[mysite.com] run: git pull origin master
...

while the other server asks for a password:

$ fab staging pull
[dev.mysite.com] Executing task 'pull'
[dev.mysite.com] run: test -d proj
[dev.mysite.com] Login password: 

The fabfile is set up pretty explicitly

def staging():
    env.hosts = ['dev.mysite.com']
    env.user = 'bamboo'
    env.key_filename = '~/.ssh/id_dsa_bamboo'

And running ssh directly from the command line works

$ ssh [email protected] -i ~/.ssh/id_dsa_bamboo
Last login: Wed Apr 11 06:24:28 2012 from xxx.xxx.xx.xx
[bamboo@dev ~]$ 

I also tried setting env.use_ssh_config = True and running with ~/.ssh/config set to

Host dev.mysite.com                                                                           
    User bamboo                                                                              
    IdentityFile ~/.ssh/id_dsa_bamboo                                                        
    ForwardAgent yes

Any ideas what could be going on? Thanks for the help.

Answer

Morgan picture Morgan · Apr 11, 2012

You can add:

ssh.util.log_to_file("paramiko.log", 10)

To the top of your fabfile, after the imports, to get more detailed information about the authorization process.