mirror of
https://github.com/rclone/rclone.git
synced 2025-01-11 00:40:03 +01:00
sftp: Add --sftp-ask-password flag to prompt for password when needed - #2137
This commit is contained in:
parent
d551137635
commit
04e055fc06
@ -5,6 +5,7 @@
|
||||
package sftp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@ -17,6 +18,7 @@ import (
|
||||
|
||||
"github.com/ncw/rclone/fs"
|
||||
"github.com/ncw/rclone/fs/config"
|
||||
"github.com/ncw/rclone/fs/config/flags"
|
||||
"github.com/ncw/rclone/fs/config/obscure"
|
||||
"github.com/ncw/rclone/fs/fshttp"
|
||||
"github.com/ncw/rclone/fs/hash"
|
||||
@ -35,6 +37,9 @@ const (
|
||||
|
||||
var (
|
||||
currentUser = readCurrentUser()
|
||||
|
||||
// Flags
|
||||
sftpAskPassword = flags.BoolP("sftp-ask-password", "", false, "Allow asking for SFTP password when needed.")
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -331,6 +336,13 @@ func NewFs(name, root string) (fs.Fs, error) {
|
||||
sshConfig.Auth = append(sshConfig.Auth, ssh.Password(clearpass))
|
||||
}
|
||||
|
||||
// Ask for password if none was defined and we're allowed to
|
||||
if pass == "" && *sftpAskPassword {
|
||||
fmt.Fprint(os.Stderr, "Enter SFTP password: ")
|
||||
clearpass := config.ReadPassword()
|
||||
sshConfig.Auth = append(sshConfig.Auth, ssh.Password(clearpass))
|
||||
}
|
||||
|
||||
f := &Fs{
|
||||
name: name,
|
||||
root: root,
|
||||
|
@ -127,6 +127,9 @@ instance `/home/$USER/.ssh/id_rsa`.
|
||||
If you don't specify `pass` or `key_file` then rclone will attempt to
|
||||
contact an ssh-agent.
|
||||
|
||||
If you set the `--sftp-ask-password` option, rclone will prompt for a
|
||||
password when needed and no password has been configured.
|
||||
|
||||
### ssh-agent on macOS ###
|
||||
|
||||
Note that there seem to be various problems with using an ssh-agent on
|
||||
@ -141,6 +144,14 @@ And then at the end of the session
|
||||
|
||||
These commands can be used in scripts of course.
|
||||
|
||||
### Specific options ###
|
||||
|
||||
Here are the command line options specific to this remote.
|
||||
|
||||
#### --sftp-ask-password ####
|
||||
|
||||
Ask for the SFTP password if needed when no password has been configured.
|
||||
|
||||
### Modified time ###
|
||||
|
||||
Modified times are stored on the server to 1 second precision.
|
||||
|
Loading…
Reference in New Issue
Block a user