mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
fix ability to log into ssh with key and password (#130)
* fix ability to log into ssh with key and password A previous refactor to the ssh password system broke the ability to use key+password to log in. This change handles key+password as a special case allowing it to be handled separately. * clean up unnecessary print My last change left in a debug print that wasn't necessary in the code. This has been removed.
This commit is contained in:
parent
e6186cd694
commit
e79dcaf910
@ -932,6 +932,22 @@ func (msh *MShellProc) isWaitingForPassword_nolock() bool {
|
||||
return pwIdx != -1
|
||||
}
|
||||
|
||||
func (msh *MShellProc) isWaitingForPassphrase_nolock() bool {
|
||||
barr := msh.PtyBuffer.Bytes()
|
||||
if len(barr) == 0 {
|
||||
return false
|
||||
}
|
||||
nlIdx := bytes.LastIndex(barr, []byte{'\n'})
|
||||
var lastLine string
|
||||
if nlIdx == -1 {
|
||||
lastLine = string(barr)
|
||||
} else {
|
||||
lastLine = string(barr[nlIdx+1:])
|
||||
}
|
||||
pwIdx := strings.Index(lastLine, "Enter passphrase for key")
|
||||
return pwIdx != -1
|
||||
}
|
||||
|
||||
func (msh *MShellProc) RunPtyReadLoop(cmdPty *os.File) {
|
||||
buf := make([]byte, PtyReadBufSize)
|
||||
var isWaiting bool
|
||||
@ -964,7 +980,11 @@ func (msh *MShellProc) WaitAndSendPassword(pw string) {
|
||||
var isWaiting bool
|
||||
var isConnecting bool
|
||||
msh.WithLock(func() {
|
||||
isWaiting = msh.isWaitingForPassword_nolock()
|
||||
if msh.Remote.SSHOpts.GetAuthType() == sstore.RemoteAuthTypeKeyPassword {
|
||||
isWaiting = msh.isWaitingForPassphrase_nolock()
|
||||
} else {
|
||||
isWaiting = msh.isWaitingForPassword_nolock()
|
||||
}
|
||||
isConnecting = msh.Status == StatusConnecting
|
||||
})
|
||||
if !isConnecting {
|
||||
|
Loading…
Reference in New Issue
Block a user