由于某种原因,Golang SSH 客户端无法连接到我的 EC2 实例。它抛出以下错误:
ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
这是我的代码:
package main
import (
"fmt"
"github.com/helloyi/go-sshclient"
)
func main() {
client, err := sshclient.DialWithKey("ip:port", "ubuntu", "my_key.pem")
if err != nil {
fmt.Println(err)
return
}
out, err := client.Cmd("help").Output()
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(out))
}
有趣的是,当我在我的另一台计算机上运行这段代码时,连接没有任何错误。所以我认为这一定是PC的问题而不是我的代码。我还尝试使用 Paramiko 客户端连接到 Python 中的实例,它工作得很好。当然,我尝试ssh在 CMD 和 MobaXTerm 客户端中使用命令进行连接 - 两者都有效。我尝试使用其他 Golang SSH 客户端golang.org/x/crypto/ssh,但没有成功(同样的错误)。
谢谢您的帮助。
走ssh
holdtom
跃然一笑
相关分类