Skip to content
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

Error on Windows #6

Open
hoegertn opened this issue Jul 7, 2019 · 3 comments
Open

Error on Windows #6

hoegertn opened this issue Jul 7, 2019 · 3 comments

Comments

@hoegertn
Copy link

hoegertn commented Jul 7, 2019

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% but ec2connect connect --instance-id i-abcd --user ec2-user --port 22 return:

panic: sending ssh key to instance: InvalidParameter: 1 validation error(s) found.
- minimum field size of 256, SendSSHPublicKeyInput.SSHPublicKey.


goroutine 1 [running]:
github.com/glassechidna/ec2connect/cmd.init.0.func1(0xc000188f00, 0xc0000dc660, 0x0, 0x6)
        /github/workspace/cmd/connect.go:34 +0x1b1
github.com/spf13/cobra.(*Command).execute(0xc000188f00, 0xc0000dc5a0, 0x6, 0x6, 0xc000188f00, 0xc0000dc5a0)
        /go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:830 +0x2b5
github.com/spf13/cobra.(*Command).ExecuteC(0x16baee0, 0xbbeb29, 0xc0000f7f88, 0xc00004c058)
        /go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914 +0x303
github.com/spf13/cobra.(*Command).Execute(...)
        /go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
main.main()
        /github/workspace/main.go:8 +0x35

Any idea what I am doing wrong? I tried it from different Windows installations. AWS credentials and region are set.

@aidansteele
Copy link
Collaborator

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.

@aidansteele
Copy link
Collaborator

aidansteele commented Jul 7, 2019

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: PowerShell/Win32-OpenSSH#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. 🤔

@hoegertn
Copy link
Author

hoegertn commented Jul 9, 2019

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants