Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fabric asks for password even though I can SSH using credential

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.

like image 972
bcattle Avatar asked Apr 11 '12 06:04

bcattle


3 Answers

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.

like image 145
Morgan Avatar answered Nov 01 '22 11:11

Morgan


For me, I had to reset SSH agent identities with:

ssh-add -D

Then add my key back with:

ssh-add -K keyname

Careful, this will delete all identities from SSH agent.

like image 10
Gabriel Bull Avatar answered Nov 01 '22 12:11

Gabriel Bull


I had to update fabric (probably after osx update):

sudo pip install --upgrade fabric
like image 2
jduhls Avatar answered Nov 01 '22 13:11

jduhls