@@ -451,9 +451,6 @@ func main() {
451
451
envString ("" , "GITSYNC_PASSWORD_FILE" , "GIT_SYNC_PASSWORD_FILE" ),
452
452
"the file from which the password or personal access token for git auth will be sourced" )
453
453
454
- flSSH := pflag .Bool ("ssh" ,
455
- envBool (false , "GITSYNC_SSH" , "GIT_SYNC_SSH" ),
456
- "use SSH for git operations" )
457
454
flSSHKeyFiles := pflag .StringArray ("ssh-key-file" ,
458
455
envStringArray ("/etc/git-secret/ssh" , "GITSYNC_SSH_KEY_FILE" , "GIT_SYNC_SSH_KEY_FILE" , "GIT_SSH_KEY_FILE" ),
459
456
"the SSH key(s) to use" )
@@ -508,6 +505,9 @@ func main() {
508
505
flDeprecatedRev := pflag .String ("rev" , envString ("" , "GIT_SYNC_REV" ),
509
506
"DEPRECATED: use --ref instead" )
510
507
mustMarkDeprecated ("rev" , "use --ref instead" )
508
+ _ = pflag .Bool ("ssh" , false ,
509
+ "DEPRECATED: this flag is no longer necessary" )
510
+ mustMarkDeprecated ("ssh" , "no longer necessary" )
511
511
flDeprecatedSyncHookCommand := pflag .String ("sync-hook-command" , envString ("" , "GIT_SYNC_HOOK_COMMAND" ),
512
512
"DEPRECATED: use --exechook-command instead" )
513
513
mustMarkDeprecated ("sync-hook-command" , "use --exechook-command instead" )
@@ -698,32 +698,6 @@ func main() {
698
698
}
699
699
}
700
700
701
- if * flSSH {
702
- if * flUsername != "" {
703
- handleConfigError (log , true , "ERROR: only one of --ssh and --username may be specified" )
704
- }
705
- if * flPassword != "" {
706
- handleConfigError (log , true , "ERROR: only one of --ssh and --password may be specified" )
707
- }
708
- if * flPasswordFile != "" {
709
- handleConfigError (log , true , "ERROR: only one of --ssh and --password-file may be specified" )
710
- }
711
- if * flAskPassURL != "" {
712
- handleConfigError (log , true , "ERROR: only one of --ssh and --askpass-url may be specified" )
713
- }
714
- if * flCookieFile {
715
- handleConfigError (log , true , "ERROR: only one of --ssh and --cookie-file may be specified" )
716
- }
717
- if len (* flSSHKeyFiles ) == 0 {
718
- handleConfigError (log , true , "ERROR: --ssh-key-file must be specified when --ssh is set" )
719
- }
720
- if * flSSHKnownHosts {
721
- if * flSSHKnownHostsFile == "" {
722
- handleConfigError (log , true , "ERROR: --ssh-known-hosts-file must be specified when --ssh-known-hosts is set" )
723
- }
724
- }
725
- }
726
-
727
701
if * flHTTPBind == "" {
728
702
if * flHTTPMetrics {
729
703
handleConfigError (log , true , "ERROR: --http-bind must be specified when --http-metrics is set" )
@@ -837,11 +811,10 @@ func main() {
837
811
}
838
812
}
839
813
840
- if * flSSH {
841
- if err := git .SetupGitSSH (* flSSHKnownHosts , * flSSHKeyFiles , * flSSHKnownHostsFile ); err != nil {
842
- log .Error (err , "can't set up git SSH" , "keyFile" , * flSSHKeyFiles , "knownHosts" , * flSSHKnownHosts , "knownHostsFile" , * flSSHKnownHostsFile )
843
- os .Exit (1 )
844
- }
814
+ // If the --repo or any submodule uses SSH, we need to know which keys.
815
+ if err := git .SetupGitSSH (* flSSHKnownHosts , * flSSHKeyFiles , * flSSHKnownHostsFile ); err != nil {
816
+ log .Error (err , "can't set up git SSH" , "keyFile" , * flSSHKeyFiles , "knownHosts" , * flSSHKnownHosts , "knownHostsFile" , * flSSHKnownHostsFile )
817
+ os .Exit (1 )
845
818
}
846
819
847
820
if * flCookieFile {
@@ -1955,16 +1928,10 @@ func (git *repoSync) SetupGitSSH(setupKnownHosts bool, pathsToSSHSecrets []strin
1955
1928
}
1956
1929
1957
1930
for _ , p := range pathsToSSHSecrets {
1958
- if _ , err := os .Stat (p ); err != nil {
1959
- return fmt .Errorf ("can't access SSH key file %s: %w" , p , err )
1960
- }
1961
1931
sshCmd += fmt .Sprintf (" -i %s" , p )
1962
1932
}
1963
1933
1964
1934
if setupKnownHosts {
1965
- if _ , err := os .Stat (pathToSSHKnownHosts ); err != nil {
1966
- return fmt .Errorf ("can't access SSH known_hosts file %s: %w" , pathToSSHKnownHosts , err )
1967
- }
1968
1935
sshCmd += fmt .Sprintf (" -o StrictHostKeyChecking=yes -o UserKnownHostsFile=%s" , pathToSSHKnownHosts )
1969
1936
} else {
1970
1937
sshCmd += " -o StrictHostKeyChecking=no"
@@ -2318,8 +2285,8 @@ OPTIONS
2318
2285
2319
2286
--add-user, $GITSYNC_ADD_USER
2320
2287
Add a record to /etc/passwd for the current UID/GID. This is
2321
- needed to use SSH with an arbitrary UID (see --ssh) . This assumes
2322
- that /etc/passwd is writable by the current UID.
2288
+ needed to use SSH with an arbitrary UID. This assumes that
2289
+ /etc/passwd is writable by the current UID.
2323
2290
2324
2291
--askpass-url <string>, $GITSYNC_ASKPASS_URL
2325
2292
A URL to query for git credentials. The query must return success
@@ -2482,18 +2449,15 @@ OPTIONS
2482
2449
details) which controls which files and directories will be checked
2483
2450
out. If not specified, the default is to check out the entire repo.
2484
2451
2485
- --ssh, $GITSYNC_SSH
2486
- Use SSH for git authentication and operations.
2487
-
2488
2452
--ssh-key-file <string>, $GITSYNC_SSH_KEY_FILE
2489
- The SSH key(s) to use when using --ssh . This flag may be specified
2490
- more than once and the environment variable will be parsed like
2491
- PATH - using a colon (':') to separate elements. If not specified,
2492
- this defaults to "/etc/git-secret/ssh".
2453
+ The SSH key(s) to use when using git over SSH . This flag may be
2454
+ specified more than once and the environment variable will be
2455
+ parsed like PATH - using a colon (':') to separate elements. If
2456
+ not specified, this defaults to "/etc/git-secret/ssh".
2493
2457
2494
2458
--ssh-known-hosts, $GITSYNC_SSH_KNOWN_HOSTS
2495
- Enable SSH known_hosts verification when using --ssh . If not
2496
- specified, this defaults to true.
2459
+ Enable SSH known_hosts verification when using git over SSH . If
2460
+ not specified, this defaults to true.
2497
2461
2498
2462
--ssh-known-hosts-file <string>, $GITSYNC_SSH_KNOWN_HOSTS_FILE
2499
2463
The known_hosts file to use when --ssh-known-hosts is specified.
@@ -2599,11 +2563,11 @@ AUTHENTICATION
2599
2563
sync.
2600
2564
2601
2565
SSH
2602
- When --ssh (GITSYNC_SSH) is specified, the --ssh- key-file
2603
- (GITSYNC_SSH_KEY_FILE) will be used. Users are strongly advised
2604
- to also use --ssh-known-hosts (GITSYNC_SSH_KNOWN_HOSTS) and
2605
- --ssh-known-hosts-file (GITSYNC_SSH_KNOWN_HOSTS_FILE) when using
2606
- SSH.
2566
+ When an SSH transport is specified, the key(s) defined in
2567
+ --ssh-key-file (GITSYNC_SSH_KEY_FILE) will be used. Users are
2568
+ strongly advised to also use --ssh-known-hosts
2569
+ (GITSYNC_SSH_KNOWN_HOSTS) and --ssh-known-hosts-file
2570
+ (GITSYNC_SSH_KNOWN_HOSTS_FILE) when using SSH.
2607
2571
2608
2572
cookies
2609
2573
When --cookie-file (GITSYNC_COOKIE_FILE) is specified, the
0 commit comments