Dear all:
I tried to test sftp function with below coding,but occurred problem as 
below. Please give me suggestions. Thanks so much.
ssh: handshake failed: ssh: unable to authenticate, attempted methods 
[none], no supported methods remain

>>>>
package main

import (
"fmt"
"github.com/pkg/sftp"
"golang.org/x/crypto/ssh"
)

func main() {

c := &ssh.ClientConfig{
User: "root", // replace this
Auth: []ssh.AuthMethod{
ssh.KeyboardInteractive(func(user, instruction string, questions []string, 
echos []bool) ([]string, error) {
// Just send the password back for all questions
answers := make([]string, len(questions))
for i, _ := range answers {
answers[i] = "12345678" // replace this
}

return answers, nil
}),
},
}

connection, err := ssh.Dial("tcp", "192.168.0.1:22", c) // replace this
if err != nil {
fmt.Println(err)
return
}

server, err := sftp.NewClient(connection)
if err != nil {
fmt.Println(err)
return
}

dir, err := server.ReadDir(".")
if err != nil {
fmt.Println(err)
return
}

for _, fi := range dir {
fmt.Println(fi.Name())
}
}

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to