This repository was archived by the owner on Jan 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -291,7 +291,7 @@ func runSSHWithKey(keyPath string, remainingArgs []string) {
291291 }
292292 if user != "" {
293293 useConfig = true
294- err = kssh .CreateDefaultUserConfigFile ()
294+ err = kssh .CreateDefaultUserConfigFile (keyPath )
295295 if err != nil {
296296 fmt .Printf ("Failed to set default user: %v\n " , err )
297297 os .Exit (1 )
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ func AddKeyToSSHAgent(keyPath string) error {
2121var AlternateSSHConfigFile = shared .ExpandPathWithTilde ("~/.ssh/kssh-config" )
2222
2323// Create an SSH config file that inherits from the default SSH config file but sets a default SSH user
24- func CreateDefaultUserConfigFile () error {
24+ func CreateDefaultUserConfigFile (keyPath string ) error {
2525 user , err := GetDefaultSSHUser ()
2626 if err != nil {
2727 return err
@@ -43,10 +43,13 @@ func CreateDefaultUserConfigFile() error {
4343 f .Close ()
4444 }
4545
46+ // This config file sets a default ssh user and a default ssh key. This ensures that kssh's signed key will be
47+ // attempted before any other keys in the ssh-agent
4648 config := fmt .Sprintf ("# kssh config file to set a default SSH user\n " +
4749 "Include config\n " +
4850 "Host *\n " +
49- " User %s\n " , user )
51+ " User %s\n " +
52+ " IdentityFile %s\n " , user , keyPath )
5053
5154 f , err := os .OpenFile (AlternateSSHConfigFile , os .O_CREATE | os .O_WRONLY , 0644 )
5255 if err != nil {
You can’t perform that action at this time.
0 commit comments