-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support authentication via .pem file within host configuration? #1392
Comments
This is something that should and can be done. Let me look into it. |
On the
|
Wow, that was fast! I will give it a try soon and let you know. Thanks a lot! Regarding where in the yaml file the Another option would be something like |
I suggested Let us first see if adding the key to remote host definition works. |
Unfortunately it did not work. Here is my # ~/.sos/hosts.yml
localhost: mbp
hosts:
mbp:
home: /Users/{USER_NAME}/
ec2-instance:
address: ec2-user@{IP_ADDRESS}
pem_file: /Users/{USER_NAME}/.ssh/{KEY_NAME}.pem
paths:
home: /home/ec2-user/ Here is my "new" workflow: # remote_test.sos
[new]
input: "new_input.txt"
output: "new_output.txt"
task: to_host="{step_input}", from_host="{step_output}", queue='ec2-instance'
sh: expand=True, stdout=step_output, stderr=step_output
ls; mv {step_input} {step_output}; ls Running sos.executor_utils.ExecuteError: [new]: [b72b27a180272ad5]: Failed to connect to ec2-instance: ec2-user@{IP_ADDRESS}: Permission denied (publickey,gssapi-keyex,gssapi-with-mic). Inspecting the sshd logs inside the EC2 instance with error: AuthorizedKeysCommand /opt/aws/bin/eic_run_authorized_keys ec2-user SHA256:XXXXXXXX failed, status 22 There is some kind of key mismatch going on – but I am far from an expert on ssh... I did find an open issue with an AWS package that could be related to this error: aws/aws-ec2-instance-connect-config#20 So it is sensible to test this code with other servers to exclude this possibility... (I could only do that by the weekend) If I try to log in manually from my terminal, it connects just fine: # just in case, I added the `ControlMaster` flags you are using and it all went fine
ssh -o "ControlMaster=auto" -o "ControlPath=~/.ssh/controlmasters/%r@%h:%p" -o "ControlPersist=10m" -i /Users/{USER_NAME}/.ssh/{KEY_NAME}.pem ec2-user@{IP_ADDRESS} A workflow based on my "old" approach works fine too. For instance, I get the correct output by running # remote_test.sos
[old]
input: "old_input.txt"
output: "old_output.txt"
ec2_host = CONFIG['hosts']['ec2-instance']
local_host = CONFIG['hosts']['mbp']
sh: expand=True
scp -i {ec2_host['pem_file']} {local_host['home']}/{step_input} {ec2_host['address']}:~/
ssh {ec2_host['address']} -i {ec2_host['pem_file']} -t 'ls; mv {step_input} {step_output}; ls'
scp -i {ec2_host['pem_file']} {ec2_host['address']}:~/{step_output} {local_host['home']} Finally, just for the record, I am using code from the |
Thanks. I do have an abandoned EC2 instance. Let me try to reproduce your problem there. |
OK, here is what I did
and get
and
Note that:
|
|
I updated SoS via pip to HEAD @ master and then I was able to reproduce what you did flawlessly. My own remote test also worked fine. I will close this issue now. Thank you so much! |
Thanks for your confirmation. I have released sos 0.21.12 with the new feature. |
Thank you so much for creating SoS. It is such a great tool!
Quick question: is there an easy way to make the host setup/configuration work with a host that requires keypair (.pem) file? I couldn't find anything about it here in the repository nor in the host configuration docs.
Let's say I want to run a job in an EC2 instance.
Right now, I am using a workaround that is clearly suboptimal because it does not take any advantage of the great features SoS has with task statements.
Here is a toy example of what I am currently doing:
sh: expand=True ssh {username}@{hostname} -v -i {pem_path} -o ServerAliveInterval=180 -o ServerAliveCountMax=3 -t '{command}'
I am aware that I could edit the server SSH config in order to use another method of authentication, but I would do that only if there is no other solution.
Thanks in advance!
The text was updated successfully, but these errors were encountered: