Skip to content

[Feature request] Add support for ssh.KeyboardInteractive type of login method #26

Description

@nICEnnnnnnnLee

func (node *Node) Connect(username string, auth ssh.AuthMethod) error {
//var hostKey ssh.PublicKey
// An SSH client is represented with a ClientConn.
//
// To authenticate with the remote server you must pass at least one
// implementation of AuthMethod via the Auth field in ClientConfig,
// and provide a HostKeyCallback.
config := &ssh.ClientConfig{
User: username,
Auth: []ssh.AuthMethod{
auth,
},
//HostKeyCallback: ssh.FixedHostKey(hostKey),
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
return nil
},
}

should be

func (node *Node) Connect(username string, pwd string) error { 
 	
 	config := &ssh.ClientConfig{ 
 		User: username, 
 		Auth: []ssh.AuthMethod{
                    ssh.Password(pwd),
                    ssh.KeyboardInteractive(func(name, instruction string, questions []string, echos []bool) ([]string, error){
                        answers := make([]string, len(questions))
                        for i := range answers {
                            answers[i] = pwd
                        }
                        return answers, nil
                    }),
                },
 		//HostKeyCallback: ssh.FixedHostKey(hostKey), 
 		HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error { 
 			return nil 
 		}, 
 	} 

or

func (node *Node) Connect(username string, auth []ssh.AuthMethod) error { 
 	
 	config := &ssh.ClientConfig{ 
 		User: username, 
 		Auth: auth,
 		//HostKeyCallback: ssh.FixedHostKey(hostKey), 
 		HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error { 
 			return nil 
 		}, 
 	} 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions