66 "archive/tar"
77 "bytes"
88 "compress/gzip"
9+ "context"
910 "encoding/base64"
1011 "encoding/json"
1112 "errors"
@@ -620,7 +621,7 @@ func change_colors(color_scheme string) (ans string, err error) {
620621 return
621622}
622623
623- func run_ssh (ssh_args , server_args , found_extra_args []string , ssh_config * SSHConfig ) (rc int , err error ) {
624+ func run_ssh (ssh_args , server_args , found_extra_args []string , ssh_config_channel <- chan * SSHConfig ) (rc int , err error ) {
624625 go shell_integration .Data ()
625626 go RelevantKittyOpts ()
626627 defer func () {
@@ -630,14 +631,11 @@ func run_ssh(ssh_args, server_args, found_extra_args []string, ssh_config *SSHCo
630631 }
631632 }()
632633 cmd := append ([]string {SSHExe ()}, ssh_args ... )
633- cd := connection_data {remote_args : server_args [1 :], ssh_config : ssh_config }
634+ cd := connection_data {remote_args : server_args [1 :]}
634635 hostname := server_args [0 ]
635636 if len (cd .remote_args ) == 0 {
636637 cmd = append (cmd , "-t" )
637638 }
638- if cd .ssh_config != nil && cd .ssh_config .RemoteCommand != "" {
639- cmd = append (cmd , "-o" , "RemoteCommand=none" )
640- }
641639 insertion_point := len (cmd )
642640 cmd = append (cmd , "--" , hostname )
643641 uname , hostname_for_match := get_destination (hostname )
@@ -780,6 +778,12 @@ func run_ssh(ssh_args, server_args, found_extra_args []string, ssh_config *SSHCo
780778 }
781779 }
782780 defer cleanup ()
781+ // Receive ssh config
782+ ssh_config := <- ssh_config_channel
783+ if ssh_config != nil && ssh_config .RemoteCommand != "" {
784+ cmd = slices .Insert (cmd , insertion_point , "-o" , "RemoteCommand=none" )
785+ }
786+ cd .ssh_config = ssh_config
783787 err = get_remote_command (& cd )
784788 if err != nil {
785789 return 1 , err
@@ -856,17 +860,18 @@ func main(cmd *cli.Command, o *Options, args []string) (rc int, err error) {
856860 if passthrough {
857861 return 1 , unix .Exec (SSHExe (), utils .Concat ([]string {"ssh" }, ssh_args , server_args ), os .Environ ())
858862 }
859- ssh_config , err := LoadSSHConfig (server_args [0 ])
860- if err != nil {
861- return 1 , err
862- }
863+
864+ ctx , cancel := context .WithCancel (context .Background ())
865+ defer cancel ()
866+ ssh_config_channel := ReadSSHConfig (ctx , server_args [0 ])
867+
863868 if os .Getenv ("KITTY_WINDOW_ID" ) == "" || os .Getenv ("KITTY_PID" ) == "" {
864869 return 1 , fmt .Errorf ("The SSH kitten is meant to run inside a kitty window" )
865870 }
866871 if ! tty .IsTerminal (os .Stdin .Fd ()) {
867872 return 1 , fmt .Errorf ("The SSH kitten is meant for interactive use only, STDIN must be a terminal" )
868873 }
869- return run_ssh (ssh_args , server_args , found_extra_args , ssh_config )
874+ return run_ssh (ssh_args , server_args , found_extra_args , ssh_config_channel )
870875}
871876
872877func EntryPoint (parent * cli.Command ) {
0 commit comments