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?