{"record":{"id":"6ed1d02f586a3aa9","repo":"kovidgoyal/kitty","slug":"s-nsetup-of-port-forward-in-ssh-controlmaster-fai","errorCode":null,"errorMessage":"%s\\nSetup of port forward in SSH ControlMaster failed with error: %w","messagePattern":"(.+?)\\\\nSetup of port forward in SSH ControlMaster failed with error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/ssh/main.go","lineNumber":747,"sourceCode":"\t\t\t}\n\t\t}\n\t\tprotocol, listen_on, found := strings.Cut(os.Getenv(\"KITTY_LISTEN_ON\"), \":\")\n\t\tif !found {\n\t\t\treturn 1, fmt.Errorf(\"Invalid KITTY_LISTEN_ON: %#v\", os.Getenv(\"KITTY_LISTEN_ON\"))\n\t\t}\n\t\tif protocol == \"unix\" && strings.HasPrefix(listen_on, \"@\") {\n\t\t\treturn 1, fmt.Errorf(\"Cannot forward kitty remote control socket when an abstract UNIX socket (%s) is used, due to limitations in OpenSSH. Use either a path based one or a TCP socket\", listen_on)\n\t\t}\n\t\tcmcmd := slices.Clone(cmd[:insertion_point])\n\t\tcmcmd = append(cmcmd, control_master_args...)\n\t\tcmcmd = append(cmcmd, \"-R\", \"0:\"+listen_on, \"-O\", \"forward\")\n\t\tcmcmd = append(cmcmd, \"--\", hostname)\n\t\tc := exec.Command(cmcmd[0], cmcmd[1:]...)\n\t\tb := bytes.Buffer{}\n\t\tc.Stdout = &b\n\t\tc.Stderr = os.Stderr\n\t\tif err := c.Run(); err != nil {\n\t\t\treturn 1, fmt.Errorf(\"%s\\nSetup of port forward in SSH ControlMaster failed with error: %w\", b.String(), err)\n\t\t}\n\t\tport, err := strconv.Atoi(strings.TrimSpace(b.String()))\n\t\tif err != nil {\n\t\t\tos.Stderr.Write(b.Bytes())\n\t\t\treturn 1, fmt.Errorf(\"Setup of port forward in SSH ControlMaster failed with error: invalid resolved port returned: %s\", b.String())\n\t\t}\n\t\tcd.listen_on = \"tcp:localhost:\" + strconv.Itoa(port)\n\t}\n\tterm, err := tty.OpenControllingTerm(tty.SetNoEcho)\n\tif err != nil {\n\t\treturn 1, fmt.Errorf(\"Failed to open controlling terminal with error: %w\", err)\n\t}\n\tcd.echo_on = term.WasEchoOnOriginally()\n\tcd.host_opts, cd.literal_env = host_opts, literal_env\n\tcd.request_data = need_to_request_data\n\tcd.hostname_for_match, cd.username = hostname_for_match, uname\n\tescape_codes_to_set_colors, err := change_colors(cd.host_opts.Color_scheme)\n\tif err == nil {","sourceCodeStart":729,"sourceCodeEnd":765,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/ssh/main.go#L729-L765","documentation":"The kitten runs ssh -R 0:<listen_on> -O forward against the ControlMaster to create a remote forward for remote control; if the ssh command itself errors, the captured stdout and the underlying error are wrapped in this message.","triggerScenarios":"exec of ssh -O forward fails (non-zero exit) — network down, master died between check and use, ssh refuses the -R forward, remote sshd forbids port forwarding.","commonSituations":"Server has AllowTcpForwarding no / DisableForwarding; connection dropped mid-setup; ControlMaster expired (ControlPersist timeout) between the functional check and the forward command.","solutions":["Re-run once — transient master death is common; then increase ControlPersist timeout","Check server sshd_config allows forwarding (AllowTcpForwarding yes)","Run ssh -O forward -R 0:<socket> manually against the master to see the raw ssh error","Verify network connectivity to the host"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep ControlPersist long enough to survive session setup","Ensure sshd allows TCP forwarding on the remote host","Retry once on master-died errors before investigating"],"tags":["kitty","ssh","port-forwarding","controlmaster"],"backgroundTag":"ssh-port-forward-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}