@@ -282,7 +282,7 @@ func provisionNewKey(config kssh.ConfigFile, keyPath string) error {
282282
283283// Run SSH with the given key. Calls os.Exit and does not return.
284284func runSSHWithKey (keyPath string , remainingArgs []string ) {
285- // Create a config file for the default user if necessary
285+ // Determine whether a default SSH user has been specified and configure it if so
286286 useConfig := false
287287 user , err := kssh .GetDefaultSSHUser ()
288288 if err != nil {
@@ -309,8 +309,8 @@ func runSSHWithKey(keyPath string, remainingArgs []string) {
309309 fmt .Printf ("\n " )
310310
311311 argumentList := []string {"-i" , keyPath , "-o" , "IdentitiesOnly=yes" }
312+ checkAndWarnOnUnspecifiedBehavior (useConfig , remainingArgs )
312313 if useConfig {
313- warnAboutAlternateConfig (remainingArgs )
314314 argumentList = append (argumentList , "-F" , kssh .AlternateSSHConfigFile )
315315 }
316316
@@ -329,12 +329,15 @@ func runSSHWithKey(keyPath string, remainingArgs []string) {
329329 os .Exit (0 )
330330}
331331
332- func warnAboutAlternateConfig (arguments []string ) {
333- for _ , arg := range arguments {
334- if arg == "-F" {
335- fmt .Println ("Warning: kssh uses the -F argument in order to implement support for default SSH users. It " +
336- "is not supported to run kssh with a default user and the -F flag. Either do not use the -F flag or run" +
337- "`kssh --clear-default-user` to reset the default SSH user. " )
332+ func checkAndWarnOnUnspecifiedBehavior (useConfig bool , arguments []string ) {
333+ if useConfig {
334+ for _ , arg := range arguments {
335+ if arg == "-F" {
336+ fmt .Println ("Warning: You passed a -F flag, but kssh also uses this argument in " +
337+ "order to implement support for a default SSH username, which you're also using. " +
338+ "Either do not use the -F flag or run `kssh --clear-default-user` to reset the " +
339+ "default SSH user and delegate this to the running CA bot." )
340+ }
338341 }
339342 }
340343}
0 commit comments