Example using tcell+tview over SSH using gliderlabs/ssh without allocating a PTY or creating a subprocess.

Demo GIF

There is a little bit of glue, but maybe not enough for a library? Plus it’s probably incomplete. Here is what it looks like to make an SSH server that shows a modal when you connect:

func main() {
	ssh.Handle(func(sess ssh.Session) {
		screen, err := NewSessionScreen(sess)
		if err != nil {
			fmt.Fprintln(sess.Stderr(), "unable to create screen:", err)

		// tview says we don't have to do this
		// when using SetScreen, but it lies
		if err := screen.Init(); err != nil {
			fmt.Fprintln(sess.Stderr(), "unable to init screen:", err)

		app := tview.NewApplication().SetScreen(screen).EnableMouse(true)

		modal := tview.NewModal().
			SetText("Do you want to quit the application?").
			AddButtons([]string{"Quit", "Cancel"}).
			SetDoneFunc(func(buttonIndex int, buttonLabel string) {
				if buttonLabel == "Quit" {

		app.SetRoot(modal, false)
		if err := app.Run(); err != nil {
			fmt.Fprintln(sess.Stderr(), err)


	log.Fatal(ssh.ListenAndServe(":2222", nil, ssh.HostKeyFile("/Users/progrium/.ssh/id_rsa")))

If you try this, change the hostkey file to something that works for you.


View Github