MCPcopy
hub / github.com/ContainerSSH/ContainerSSH / GetAuthMethods

Method GetAuthMethods

internal/sshserver/TestUser.go:95–124  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93}
94
95func (u *TestUser) GetAuthMethods() []ssh.AuthMethod {
96 var result []ssh.AuthMethod
97 if u.password != "" {
98 result = append(result, ssh.Password(u.password))
99 }
100 var pubKeys []ssh.Signer
101 for _, privateKey := range u.privateKeys {
102 signer, err := ssh.NewSignerFromKey(privateKey)
103 if err != nil {
104 panic(err)
105 }
106 pubKeys = append(pubKeys, signer)
107 }
108 result = append(result, ssh.PublicKeys(pubKeys...))
109
110 if len(u.keyboardInteractive) > 0 {
111 result = append(result, ssh.KeyboardInteractive(
112 func(user, instruction string, questions []string, echos []bool) (answers []string, err error) {
113 for _, question := range questions {
114 if answer, ok := u.keyboardInteractive[question]; ok {
115 answers = append(answers, answer)
116 } else {
117 return nil, fmt.Errorf("unexpected keybord-interactive challenge: %s", question)
118 }
119 }
120 return answers, nil
121 }))
122 }
123 return result
124}

Callers 2

TestKeepAliveFunction · 0.95
ConnectMethod · 0.80

Calls 3

PasswordMethod · 0.65
KeyboardInteractiveMethod · 0.65
ErrorfMethod · 0.65

Tested by 1

TestKeepAliveFunction · 0.76