Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7693853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:11:06+00:00 2026-05-31T21:11:06+00:00

Firstly I tried to get fabric working, but it kept asking me for a

  • 0

Firstly I tried to get fabric working, but it kept asking me for a password.

So I’m trying to reduce the problem. Perhaps it would be a good POC to just create a SSH connection from Python. I discovered that fabric uses parmiko for it’s SSH handling. Hmm. Ok, lets try to get an example working.

Here’s what I wrote.

from ssh import *
import os 

print "SSH-AGENT VARS"

print "SSH_AGENT_PID: %s " % os.environ['SSH_AGENT_PID']
print "SSH_AUTH_SOCK: %s " % os.environ['SSH_AUTH_SOCK']

a = Agent()
keys=a.get_keys()
print keys.count("192.168.1.10")


client = SSHClient()
client.load_system_host_keys()
client.connect('192.168.1.10')

Resulting in the following error messages:

% ./ssh_test.py
SSH-AGENT VARS
SSH_AGENT_PID: 26557 
SSH_AUTH_SOCK: /tmp/ssh-pZHBElj26556/agent.26556 
0
Traceback (most recent call last):
  File "./ssh_test.py", line 18, in <module>
    client.connect('192.168.1.10')
  File "/usr/local/lib/python2.7/dist-packages/ssh/client.py", line 332, in connect
    self._auth(username, password, pkey, key_filenames, allow_agent, look_for_keys)
  File "/usr/local/lib/python2.7/dist-packages/ssh/client.py", line 493, in _auth
    raise saved_exception
ssh.PasswordRequiredException: Private key file is encrypted

ssh-agent is running in my session, I can SSH to that box, no problems, it doesn’t prompt me for a password or anything.

I’m guessing paramiko isn’t able to connect to the running ssh-agent for some weird reason.

Has anyone else had a problem like this? I’m using Ubuntu 11.10

I seem to remember trying Fabric a while back and having similar problems, perhaps it’s been broken for a while?

I connect, just using the host name as the argument. This is as per the documentation.

http://www.lag.net/paramiko/docs/paramiko.SSHClient-class.html

connect(self, hostname, port=22, username=None, password=None, pkey=None, key_filename=None, timeout=None, allow_agent=True, look_for_keys=True, compress=False)
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:11:08+00:00Added an answer on May 31, 2026 at 9:11 pm

    Ok, so the first thing I discovered was that Paramiko is way out of date, and unmaintained.

    It’s now known as package ssh, at least under Ubuntu, and has a different maintainer (bitprophet)

    • Here’s a demo class that works exactly as described:
      https://raw.github.com/bitprophet/ssh/master/demos/demo.py

    • It requires this file, for interactive prompts:
      https://github.com/bitprophet/ssh/blob/master/demos/interactive.py

    Here’s a sample session, using it:

    $ ./ssh_demo.py
    Hostname: 192.168.1.10
    *** Host key OK.
    Username [bryan]: root
    Trying ssh-agent key eee5638f390e1698898984b10adfa9317 ... success!
    *** Here we go!
    
    Linux top.secret.com 2.9.37-1-amd64 #1 SMP Thu Nov 3 03:41:26 UTC 2011 x86_64
    ┌┌(root@top)-(10:44am-:-03/27)┌-¨-¨¨˙
    

    That doesn’t answer the question of why fabric isn’t authenticating against the ssh-agent correctly thought. So the question remains open.

    Update:

    Thanks to Morgan’s hint, I’ve gotten a little further with this problem. As he suggested, I enabled ssh logging by adding the following to the top of my fabfile.py

    from fabric.api import *
    import ssh
    ssh.util.log_to_file("paramiko.log", 10)
    

    I also monitored the server log. In doing so I discovered that the user which I specified was being disregarded and my local username used instead.

    On the server:

    tail -f /var/log/auth.log 
    Mar 28 11:12:36 xxxxxxxxxxx sshd[17652]: Invalid user bryan from xxx.xxx.xxx.xxx
    

    Locally:

    tail -f paramiko.log    
    DEB [20120328-11:39:29.038] thr=1   ssh.transport: starting thread (client mode): 0x8dfc66cL
    INF [20120328-11:39:29.066] thr=1   ssh.transport: Connected (version 2.0, client OpenSSH_5.5p1)
    DEB [20120328-11:39:29.093] thr=1   ssh.transport: kex algos:['diffie-hellman-group-exchange-sha256', 'diffie-hellman-group-exchange-sha1', 'diffie-hellman-group14-sha1', 'diffie-hellman-group1-sha1'] server key:['ssh-rsa', 'ssh-dss'] client encrypt:['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'arcfour256', 'arcfour128', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'aes192-cbc', 'aes256-cbc', 'arcfour', 'rijndael-cbc@lysator.liu.se'] server encrypt:['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'arcfour256', 'arcfour128', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'aes192-cbc', 'aes256-cbc', 'arcfour', 'rijndael-cbc@lysator.liu.se'] client mac:['hmac-md5', 'hmac-sha1', 'umac-64@openssh.com', 'hmac-ripemd160', 'hmac-ripemd160@openssh.com', 'hmac-sha1-96', 'hmac-md5-96'] server mac:['hmac-md5', 'hmac-sha1', 'umac-64@openssh.com', 'hmac-ripemd160', 'hmac-ripemd160@openssh.com', 'hmac-sha1-96', 'hmac-md5-96'] client compress:['none', 'zlib@openssh.com'] server compress:['none', 'zlib@openssh.com'] client lang:[''] server lang:[''] kex follows?False
    DEB [20120328-11:39:29.093] thr=1   ssh.transport: Ciphers agreed: local=aes128-ctr, remote=aes128-ctr
    DEB [20120328-11:39:29.093] thr=1   ssh.transport: using kex diffie-hellman-group1-sha1; server key type ssh-rsa; cipher: local aes128-ctr, remote aes128-ctr; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none
    DEB [20120328-11:39:29.183] thr=1   ssh.transport: Switch to new keys ...
    DEB [20120328-11:39:29.224] thr=2   ssh.transport: Trying SSH agent key cda5638f390e166864444b1093b91017
    DEB [20120328-11:39:29.272] thr=1   ssh.transport: userauth is OK
    INF [20120328-11:39:53.310] thr=1   ssh.transport: Authentication (publickey) failed.
    DEB [20120328-11:41:29.076] thr=1   ssh.transport: EOF in transport thread
    

    Hmm, that’s strange, I ran the command as:
    fab diskfree -H xxx.xxx.xxx.xxx -u root

    But what is this?

    $ cat ./fabfile.py
    from fabric.api import *
    import ssh
    ssh.util.log_to_file("paramiko.log", 10)
    
    env.user = 'bryan'
    
    def host_type():
     run('uname -s')
    
    def diskfree():
     run('df -h') 
    

    Hmm

    env.user = 'bryan'
    

    Could that be the root of the problem? Could the ssh error messages just be misleading me?

    I removed the line and it worked, so I guess so, is the answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem I tried solving on my own, but didn't get far
I've been trying to invoke D3 within Node.js. I tried firstly to import d3.v2.js
I have tried $_SERVER['HTTP_USER_AGENT'], but we didn't get the exact name. Then i have
I tried to get the home site of a url. Firstly I used a
Firstly I tried fiding some similar posts but could not quite find anything. Mainly
Firstly, I have tried the method given in official page of eclipse . But
I have tried hours and hours of examples but I continually get the same
I'm trying to get tags working in my rails application and want to use
Firstly, apologies for all the XAML. I've tried for a few days to resolve
Firstly, I have search Stack Overflow for the answer, but I have not found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.