forked from x/icebergs
opt some
This commit is contained in:
parent
e16c6b4b65
commit
f7e023d861
@ -1,8 +1,6 @@
|
|||||||
package ssh
|
package ssh
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/aaa"
|
"github.com/shylinux/icebergs/base/aaa"
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
@ -14,6 +12,7 @@ import (
|
|||||||
"golang.org/x/crypto/ssh/terminal"
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
@ -24,19 +23,19 @@ import (
|
|||||||
func _ssh_conn(m *ice.Message, conn net.Conn, username, hostport string) (*ssh.Client, error) {
|
func _ssh_conn(m *ice.Message, conn net.Conn, username, hostport string) (*ssh.Client, error) {
|
||||||
methods := []ssh.AuthMethod{}
|
methods := []ssh.AuthMethod{}
|
||||||
methods = append(methods, ssh.KeyboardInteractive(func(user, instruction string, questions []string, echos []bool) (res []string, err error) {
|
methods = append(methods, ssh.KeyboardInteractive(func(user, instruction string, questions []string, echos []bool) (res []string, err error) {
|
||||||
for _, k := range questions {
|
for _, q := range questions {
|
||||||
switch strings.TrimSpace(strings.ToLower(k)) {
|
p := strings.TrimSpace(strings.ToLower(q))
|
||||||
case "verification code:":
|
switch {
|
||||||
if m.Option("verify") == "" {
|
case strings.HasSuffix(p, "verification code:"):
|
||||||
verify := ""
|
if verify := m.Option("verify"); verify == "" {
|
||||||
fmt.Println("verify code: \n")
|
fmt.Printf(q)
|
||||||
fmt.Println("verify code: ")
|
|
||||||
fmt.Scanf("%6s", &verify)
|
fmt.Scanf("%6s", &verify)
|
||||||
|
|
||||||
res = append(res, verify)
|
res = append(res, verify)
|
||||||
return
|
} else {
|
||||||
|
res = append(res, aaa.TOTP_GET(verify, 6, 30))
|
||||||
}
|
}
|
||||||
res = append(res, aaa.TOTP_GET(m.Option("verify"), 6, 30))
|
case strings.HasSuffix(p, "password:"):
|
||||||
case "password:":
|
|
||||||
res = append(res, m.Option(aaa.PASSWORD))
|
res = append(res, m.Option(aaa.PASSWORD))
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user