Open hoegertn opened 5 years ago
I think it's likely you are doing nothing wrong and it's just a bug in ec2connect
! I won't have access to a Windows machine for a few hours, but in the mean time we can try to debug this.
Can you share the contents of your ~/.ssh/ec2connect/ssh_config
file? I'm guessing it might be a file path issue, e.g. forward slashes vs back slashes, etc.
Looks like I have my work cut out for me on Windows. This is what I have so far:
PS C:\Users\Administrator> ssh -vvv ec2-user@i-026bbf8b58ea1a442
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1: Reading configuration data C:\\Users\\Administrator/.ssh/config
debug1: C:\\Users\\Administrator/.ssh/config line 1: include ~/.ssh/C:\\Users\\Administrator\\.ssh\\ec2connect/ssh_config matched no files
debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2
debug2: resolving "i-026bbf8b58ea1a442" port 22
ssh: Could not resolve hostname i-026bbf8b58ea1a442: No such host is known.
At this point I modified ~/.ssh/config
to read Include ec2connect/ssh_config
(i.e. a relative path rather than absolute). Then I got this:
PS C:\Users\Administrator> ssh -vvv ec2-user@i-026bbf8b58ea1a442
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1: Reading configuration data C:\\Users\\Administrator/.ssh/config
debug3: C:\\Users\\Administrator/.ssh/config line 1: Including file C:\\Users\\Administrator/.ssh/ec2connect/ssh_config depth 0
debug1: Reading configuration data C:\\Users\\Administrator/.ssh/ec2connect/ssh_config
debug2: checking match for 'exec "ec2connect match --host %n --user %r"' host i-026bbf8b58ea1a442 originally i-026bbf8b58ea1a442
debug3: C:\\Users\\Administrator/.ssh/ec2connect/ssh_config line 2: matched 'exec "ec2connect match --host i-026bbf8b58ea1a442 --user ec2-user"'
debug2: match found
debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2
debug1: Executing proxy command: exec ec2connect connect --instance-id i-026bbf8b58ea1a442 --user ec2-user --port 22
debug3: spawning "C:\\Windows\\System32\\OpenSSH\\ec2connect connect --instance-id i-026bbf8b58ea1a442 --user ec2-user --port 22"
CreateProcessW failed error:2
posix_spawn: No such file or directory
For some reason (that I haven't yet investigated), it is trying to execute C:\Windows\System32\OpenSSH\ec2connect
rather than using the one on the PATH. I'll keep digging.
EDIT: Looks like this was addressed in 7.9, but my default installation is 7.7: https://github.com/PowerShell/Win32-OpenSSH/issues/1185.
I then modified my ~/.ssh/ec2connect/ssh_config
to read ProxyCommand C:\Users\Administrator\scoop\shims\ec2connect.exe connect --instance-id %h --user %r --port %p
and it now works. You should be able to use this workaround until I am able to fix this in the next version of ec2connect
EDIT 2: Reviewing your first post, it appears this probably won't fix your issue as your error message is unrelated. 🤔
After doing these changes the original error went away and I could reproduce your errors. But at the end I get
debug1: No more authentication methods to try.
e2-user@i-abcd: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
When I try to connect using Windows I get the error
ssh: Could not resolve hostname i-abcd:
The command
ec2connect match ...
is returning the correct%errorlevel%
butec2connect connect --instance-id i-abcd --user ec2-user --port 22
return:Any idea what I am doing wrong? I tried it from different Windows installations. AWS credentials and region are set.