easyssh-proxy
easyssh-proxy copied to clipboard
Handshake failed: ssh: unable to authenticate
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
...
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