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 8010615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:47:34+00:00 2026-06-04T18:47:34+00:00

decided to give Python a try for the first time, so sorry if the

  • 0

decided to give Python a try for the first time, so sorry if the answer is obvious.

I’m trying to create an ssh connection using paramiko. I’m using the below code:

#!/home/bin/python2.7

import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh.connect("somehost.com", username="myName", pkey="/home/myName/.ssh/id_rsa.pub")
stdin, stdout, stderr = ssh.exec_command("ls -l")

print stdout.readlines()
ssh.close()

Pretty standard stuff, right? Except I’m getting this error:

 ./test.py
Traceback (most recent call last):
File "./test.py", line 10, in <module>
ssh.connect("somehost", username="myName", pkey="/home/myName/.ssh/id_rsa.pub")
File "/home/lib/python2.7/site-packages/paramiko/client.py", line 327, in connect
self._auth(username, password, pkey, key_filenames, allow_agent, look_for_keys)
File "/home/lib/python2.7/site-packages/paramiko/client.py", line 418, in _auth
self._log(DEBUG, 'Trying SSH key %s' % hexlify(pkey.get_fingerprint()))
AttributeError: 'str' object has no attribute 'get_fingerprint'

What “str” object is it referring to? I thought I merely had to pass it the path to the RSA key but it seems to be wanting some object.

  • 1 1 Answer
  • 0 Views
  • 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-06-04T18:47:35+00:00Added an answer on June 4, 2026 at 6:47 pm

    The pkey parameter should be the actual private key, not the name of the file containing the key. Note that pkey should be a PKey object and not a string (e.g. private_key = paramiko.RSAKey.from_private_key_file (private_key_filename) ).
    Instead of pkey you could use the key_filename parameter to pass the filename directly.

    See the documentation for connect.

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

Sidebar

Related Questions

I'm new to python an I decided to give it a try with TG2
I'm used to using Idle for Python development, but decided to give Visual Studio
I'm coming from a TortoiseSVN background and decided to give TortoiseHg a try. One
I decided to give PHP a try, and then bought lynda.com's essential training tutorial.
On our development team, we decided to give Unit Testing a try. We use
I decided to give Nokogiri a try, and copied the following program straight from
I decided to give MongoDB a try and see how well we get along.
I've decided to give Quartz.net a go. Now I am trying to figure out
I've decided to give Dojo a shot instead of using JQuery for once, and
I recently decided to give matplotlib.pyplot a try, while having used gnuplot for scientific

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.