Panic: Failed to dial: ssh: handshake failed

Hello Forum,

I have a go module which makes ssh connection with the remote hosts.

for some reason it fails with the below error, while trying to make initial connection.

panic: Failed to dial: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remai`` goroutine 1 [running]: main.main()

config := &ssh.ClientConfig{
	User: os.Getenv("USER"),
	Auth: []ssh.AuthMethod{
	HostKeyCallback: ssh.InsecureIgnoreHostKey(),

client, err := ssh.Dial("tcp", "<remotehost>:22", config)
if err != nil {
	panic("Failed to dial: " + err.Error())

I am a golang newbie so please take what I say with a pinch of salt but, did you try accessing the server manually by running the SSH command instead of the script?

Long time ago I had done some scripting in Perl and I was getting a lot of failure errors. Turned out that the SSH connection was not working because SSH was disabled on one server and on another server the username was not created.
Hope this helps.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.