F
F
fdroid2017-07-29 18:33:10
SSH
fdroid, 2017-07-29 18:33:10

How to set up automatic RSA key password entry?

Hello. You need to set up rsync backup from NAS running Nas4Free to Synology NAS. I configured SSH authorization by RSA key on N4F, the key is password protected. I found a script running on Synology to solve the specified task:

#!/bin/sh
USER="username"
SERVER="server.name"
PORT="22"
SSHID="/volume1/homes/admin/backups/websites/.ssh/id_rsa"
SOURCE="/home/username/public_html/"
TARGET="/volume1/homes/admin/backups/websites/sitename/"
LOG="/volume1/homes/admin/backups/websites/logs/sitename.log"

/usr/syno/bin/rsync -avz --delete --progress -e "ssh -p $PORT -i $SSHID" $USER@$SERVER:$SOURCE $TARGET >> $LOG 2>&1

Now explanations.
username - the username used to access the remote server via SSH.
server.name - domain name of the remote server from which we will copy files to the NAS
PORT - port for accessing the remote server via SSH
SSHID - path to the id_rsa file of the "private" key that we saved on the NAS.
SOURCE - the absolute path on the remote server to the directory that we will copy to the NAS.
TARGET - absolute path to the NAS directory where everything is copied. You need to set write permissions for the directory.
LOG - we will write the output of rsync to the logs, it will help to catch problems if they arise. In the LOG variable, the path to the file. Let the file be called sitename.log
The last line is the command itself, which will synchronize the remote directory on the NAS. How it should look - depends solely on your desires. To get all rsync keys, log in to your NAS via SSH and run the command
(explained by the script author)
rsync -h > /volume1/homes/admin/backups/websites/rsync_help.txt

In principle, everything is clear, except for the moment that this script does not provide for entering the key password, it implies the use of just a key file, but this does not suit me.
Question: how to change the script so that it takes into account the key password?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2017-07-29
@fdroid

As a rule, in such cases, they just use keys without a password.
you can try to enter the password using the expect utility , but:
1. not sure that it exists for your us.
2. the very meaning of the idea is not clear.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question