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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:25:02+00:00 2026-06-14T17:25:02+00:00

I am trying to SSH into a running EC2 instance but it gives the

  • 0

I am trying to SSH into a running EC2 instance but it gives the following error every time.

import os
import boto.manage.cmdshell

ec2 = boto.connect_ec2()
key_dir= '~/'
key_name='keypair'
key_extension='.pem'
key_path = os.path.join(os.path.expanduser(key_dir),
                    key_name+key_extension)
reservations = ec2.get_all_instances()
instance = reservations[0].instances[0]

cmd = boto.manage.cmdshell.sshclient_from_instance(instance,
                                               key_path,
                                               host_key_file='~/.ssh/known_hosts',
                                               user_name='ec2-user')

cmd.shell()

Traceback (most recent call last):
File “/home/…/FirstModule.py”, line 26, in cmd.shell()
File “/usr/lib/python2.7/dist-packages/boto/manage/cmdshell.py”, line 114, in shell
interactive_shell(channel)
File “/usr/lib/python2.7/dist-packages/boto/mashups/interactive.py”, line 34, in interactive_shell
posix_shell(chan)
File “/usr/lib/python2.7/dist-packages/boto/mashups/interactive.py”, line 42, in posix_shell
oldtty = termios.tcgetattr(sys.stdin)
termios.error: (22, ‘Invalid argument’)

Any clue why this error is showing up?

  • 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-14T17:25:04+00:00Added an answer on June 14, 2026 at 5:25 pm

    One possibility is that the path name to the hosts file is not a raw string. It might help to do it as follows:

    cmd = boto.manage.cmdshell.sshclient_from_instance(
              instance,
              key_path,
              host_key_file=r'~/.ssh/known_hosts',
              user_name='ec2-user'
           )
    

    You might also want to quote the key_dir value as well.

    key_dir = r'~/'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use pexpect to ssh into a computer but I do
In the following command i am trying to ssh commands and execute the multiple
I have a server that I can ssh into but that's it. Otherwise it
I am trying to ssh into github. I have generated an ssh key in
I'm trying to ssh into a server and run a python script on it.
I am trying to ssh into a remote Linux server using x11. I found
I am fairly new to scripting with perl. I am trying to ssh into
I'm currently trying to ssh into a remote machine and run a script, then
On MAC OS X Lion - Running MAMP I'm trying to execute the following
I'm trying to write a Bash script that will SSH into a machine and

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.