in fast-build-update-tool/internal/tools/ssh_enabler.go [180:201]
func (w *ptyWriter) Write(p []byte) (int, error) {
terminalOutputStr := string(p)
// If we have a new command input (eg. `sh $`), let the channel know we can accept the next command.
if w.isNewCommandOutput(terminalOutputStr) && w.commandsRun < w.commandsToAccept {
w.commandsRun = w.commandsRun + 1
w.commandReady <- w.commandsRun
// Everything has run, close the channel
if w.commandsToAccept <= w.commandsRun {
close(w.commandReady)
}
}
// We'll cat the public key file, make sure we capture the output, we need this to connect to the server later on
match := FindED25519PublicKey(terminalOutputStr)
if match != "" && !strings.Contains(w.clientPublicKey, match) {
w.logger.Debug("found server public key", "key", match)
w.sshKeyReady <- match
}
return len(p), nil
}