We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The following code does not work either with powershell.exe and cmd.exe.
I can't type anything when the session starts ..
func GiveShell(s ssh.Session) { _, _, isPty := s.Pty() if isPty { logger.Get().Info("PTY requested") cmd := exec.Command("cmd") stdin, err := cmd.StdinPipe() if err != nil { logger.Get().Warn("Error occured: %s") return } stdout, err := cmd.StdoutPipe() if err != nil { logger.Get().Warn("Error occured: %s", err) return } stderr, err := cmd.StderrPipe() if err != nil { logger.Get().Warn("Error occured: %s", err) return } go func() { io.Copy(stdin, s) }() go func() { io.Copy(s, stdout) }() go func() { io.Copy(s, stderr) }() err = cmd.Run() if err == nil { logger.Get().Info("Session ended normally") s.Exit(0) } else { logger.Get().Info("Session ended with an error: %v\n", err) exitCode := 1 if exitError, ok := err.(*exec.ExitError); ok { exitCode = exitError.ExitCode() logger.Get().Info("exit code: %d\n", exitCode) } s.Exit(exitCode) } } else { msg := "No PTY requested." io.WriteString(s, msg) logger.Get().Warn(msg) } }
The text was updated successfully, but these errors were encountered:
#214
Sorry, something went wrong.
No branches or pull requests
The following code does not work either with powershell.exe and cmd.exe.
I can't type anything when the session starts ..
The text was updated successfully, but these errors were encountered: