diff --git a/obfscp/scp.go b/obfscp/scp.go index 002cc24..5707a68 100644 --- a/obfscp/scp.go +++ b/obfscp/scp.go @@ -14,13 +14,13 @@ import ( "syscall" "time" - "github.com/bgentry/speakeasy" "github.com/fangdingjun/go-log/v5" "github.com/fangdingjun/obfssh" "github.com/kr/fs" "github.com/pkg/sftp" "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" + "golang.org/x/crypto/ssh/terminal" ) type options struct { @@ -577,8 +577,10 @@ func makeDirs(p string, c dirInterface) error { func passwordAuth() (string, error) { // read password from console - s, err := speakeasy.Ask("Password: ") - return strings.Trim(s, " \r\n"), err + fmt.Fprintf(os.Stdout, "Password: ") + s, err := terminal.ReadPassword(int(os.Stdin.Fd())) + fmt.Fprintf(os.Stdout, "\n") + return strings.Trim(string(s), " \r\n"), err } // diff --git a/obfssh/ssh.go b/obfssh/ssh.go index 6c2fa2c..7e36f9c 100644 --- a/obfssh/ssh.go +++ b/obfssh/ssh.go @@ -11,11 +11,11 @@ import ( "strings" "time" - "github.com/bgentry/speakeasy" "github.com/fangdingjun/go-log/v5" "github.com/fangdingjun/obfssh" "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" + "golang.org/x/crypto/ssh/terminal" ) var dialer = &net.Dialer{Timeout: 15 * time.Second} @@ -383,8 +383,10 @@ func keyboardAuth(user, instruction string, question []string, echos []bool) (an func passwordAuth() (string, error) { // read password from console - s, err := speakeasy.Ask("Password: ") - return strings.Trim(s, " \r\n"), err + fmt.Fprintf(os.Stdout, "Password: ") + s, err := terminal.ReadPassword(int(os.Stdin.Fd())) + fmt.Fprintf(os.Stdout, "\n") + return strings.Trim(string(s), " \r\n"), err } func usage() {