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

Handshake failed: ssh: unable to authenticate #69

Open
gopherunner opened this issue Jun 18, 2021 · 1 comment
Open

Handshake failed: ssh: unable to authenticate #69

gopherunner opened this issue Jun 18, 2021 · 1 comment

Comments

@gopherunner
Copy link

Hi, I'm trying to run a remote command to a host but it fails with the following error message and I can't find what is wrong:

ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

Here is the code:

const (
    PKEY = "/root/.ssh/id_rsa"
)
...
output, err := utils.RunSSHCommand(user, host, PKEY, "cat /some/file")
...
func RunSSHCommand(user, addr, key, cmd string) (string, error) {
	ssh := &easyssh.MakeConfig{
		User:    user,
		Server:  addr,
		KeyPath: key,
		Port:    "22",
		Timeout: 60 * time.Second,
	}
	stdout, stderr, done, err := ssh.Run(cmd, 60*time.Second)
	if err != nil {
		color.Error.Printf("[SSH Error] Cant run remote command (%s), error msg: %s\n", cmd, err.Error())
	} else {
		if done {
			return stdout, err
		} else {
			color.Error.Printf("[SSH Error] Command error execution msg: %s\n", stderr)
		}
	}
	return "", err
}

Any ideas of what could be the problem here? I've already check that the key exists. I'm running this code from a docker container, and I pass the private key from the server running the container to the container it self on the docker-compose file like these:

...
volumes:
- /root/.ssh/id_rsa:/root/.ssh/id_rsa
...
@stanvarlamov
Copy link

It may be helpful for those who get here troubleshooting the above-reported error: for the 2021/22 timeframe specifically, check this Group link out and ensure you have the latest crypto/ssh running

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