I have a cluster on AWS that I want to SSH into with boto.cmdshell
. however maybe I'm not understanding the parameters to pass.
The node has the user ubuntu
and no passphrase set.
ssh_client = sshclient_from_instance(instanceobj,
ssh_key_file =r'C:\Users\Neil\Downloads\sparkcluster.pem',
user_name ='ubuntu')`
I get this error when I run the code:
[Errno 2] No such file or directory: 'C:\\\\Users\\\\Neil/.ssh/known_hosts'
This error makes no sense to me :/, I thought I am supposed provide the pem key to the ssh_key_file
parameter. Am I missing something? I know sshing with putty works just fine.
Any help would be awesome!
From what I know and as per the github code of boto , there is one more argument called host_key_file
whose default value if not specified by the caller is ~/.ssh/known_hosts
. In your case, you don't have that file at your home directory C:\\Users\\Neil
. Hence, you get this error.
If you are connecting from a Ubuntu or linux based machine
Add the below lines at the end of /etc/ssh/ssh_config
file :
Host IP_YOU_WANT_TO_CONNECT
IdentityFile path/keyname.pem
StrictHostKeyChecking no
or do this:
sudo touch ~/.ssh/known_hosts
ssh-keyscan -H [hostname],[ip_address] >> ~/.ssh/known_hosts
In the first case, you may have to specify /etc/ssh/ssh_config
as host_key_file
. In the second case, the default argument value will work.
There is an equivalent option for windows as well. If you search, you can get lot of information. From what I know, you can install openSSH for windows and C:\\Program Files\\OpenSSH\\etc\\ssh_config
is the equivalent of what I posted above for windows. Fill in the information like above in that file. You can then specify this as the host_key_file.
I think you may also manually create a .ssh/ssh_config file in your home directory C:\\Users\\Neil
and do something similar to ssh-keyscan I have done above for linux. But, I have never tried this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.