mirror of
https://github.com/rclone/rclone.git
synced 2025-07-16 12:15:25 +02:00
Created Export configuration password to env variable and only remember it for some time (markdown)
@ -0,0 +1,28 @@
|
||||
As [configuration encryption docs](https://rclone.org/docs/#configuration-encryption) mention:
|
||||
> If it is safe in your environment, you can set the `RCLONE_CONFIG_PASS` environment variable to contain your password, in which case it will be used for decrypting the configuration.
|
||||
|
||||
It also provides a short script to do so, which can be improved to only remember your password for some time (similar to `sudo`). For Unix like systems you can save this to a file somewhere in your `$PATH`, e.g. `~/.local/bin/rclone-unlock`
|
||||
|
||||
```sh
|
||||
#!/bin/echo Source this file don't run it
|
||||
|
||||
echo "Password:"
|
||||
|
||||
read -s RCLONE_CONFIG_PASS
|
||||
export RCLONE_CONFIG_PASS
|
||||
|
||||
if [ -n $RCLONE_PASS_TIMEOUT ]; then
|
||||
pid=$$
|
||||
trap 'unset RCLONE_CONFIG_PASS' SIGALRM
|
||||
( ( sleep $RCLONE_PASS_TIMEOUT ; kill -ALRM $pid ) & )
|
||||
|
||||
echo -n "Password will be remembered in this session for $RCLONE_PASS_TIMEOUT"
|
||||
[[ $RCLONE_PASS_TIMEOUT =~ [smhd] ]] && echo || echo " seconds"
|
||||
fi
|
||||
```
|
||||
|
||||
Then source this file when you want to use it: `. rclone-unlock`. It will then ask you for the password and set it in the environment variable.
|
||||
|
||||
If you set password timeout to some amount of time (in format [`sleep`](https://manpages.debian.org/testing/coreutils/sleep.1.en.html) accepts) with `RCLONE_PASS_TIMEOUT` environment variable, `RCLONE_CONFIG_PASS` will be unset after that time.
|
||||
|
||||
You can also clear `RCLONE_CONFIG_PASS` sourcing `rclone-unlock` as usual and then just hitting <kbd>Enter</kbd> (thus setting empty password).
|
Reference in New Issue
Block a user