mirror of
https://github.com/kopia/kopia.git
synced 2026-03-13 03:36:34 -04:00
cli: add missing options for configuring sftp known_hosts
Possibly the cause of #414
This commit is contained in:
@@ -28,6 +28,8 @@ func(cmd *kingpin.CmdClause) {
|
||||
cmd.Flag("username", "SFTP/SSH server username").Required().StringVar(&options.Username)
|
||||
cmd.Flag("keyfile", "path to private key file for SFTP/SSH server").StringVar(&options.Keyfile)
|
||||
cmd.Flag("key-data", "private key data").StringVar(&options.KeyData)
|
||||
cmd.Flag("known-hosts", "path to known_hosts file").StringVar(&options.KnownHostsFile)
|
||||
cmd.Flag("known-hosts-data", "known_hosts file entries").StringVar(&options.KnownHostsData)
|
||||
cmd.Flag("embed-credentials", "Embed key and known_hosts in Kopia configuration").BoolVar(&embedCredentials)
|
||||
cmd.Flag("flat", "Use flat directory structure").BoolVar(&connectFlat)
|
||||
},
|
||||
@@ -35,13 +37,25 @@ func(ctx context.Context, isNew bool) (blob.Storage, error) {
|
||||
sftpo := options
|
||||
|
||||
if embedCredentials {
|
||||
d, err := ioutil.ReadFile(sftpo.Keyfile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if sftpo.KeyData == "" {
|
||||
d, err := ioutil.ReadFile(sftpo.Keyfile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sftpo.KeyData = string(d)
|
||||
sftpo.Keyfile = ""
|
||||
}
|
||||
|
||||
sftpo.KeyData = string(d)
|
||||
sftpo.Keyfile = ""
|
||||
if sftpo.KnownHostsData == "" && sftpo.KnownHostsFile != "" {
|
||||
d, err := ioutil.ReadFile(sftpo.KnownHostsFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sftpo.KnownHostsData = string(d)
|
||||
sftpo.KnownHostsFile = ""
|
||||
}
|
||||
}
|
||||
|
||||
if sftpo.KeyData == "" && sftpo.Keyfile == "" {
|
||||
|
||||
Reference in New Issue
Block a user