/etc/ssh содержит пары закрытый и открытый ключи для хоста (компьютер/операционная система)
~/.ssh содержит пары ключей для пользователя-владельца
Немного изучите, как работают симметричные ключи и PKI. Вы обнаружите, что в большинстве ситуаций и отправителю, и получателю требуется собственная пара закрытых/открытых ключей.
Флаг --existing
— это то, что вам нужно. Со страницы руководства:
--existing, --ignore-non-existing
This tells rsync to skip creating files (including
directories) that do not exist yet on the destination. If this option is combined
with the --ignore-existing option, no files will be updated (which can be useful
if all you want to do is delete extraneous files).
This option is a transfer rule, not an exclude, so it doesn’t affect the data that
goes into the file-lists, and thus it doesn’t affect deletions. It just limits
the files that the receiver requests to be transferred.
Вы можете использовать такой сценарий.
(
cd destination &&
for d in *
do
[ -d "$d" -a -d source/"$d" ] && rsync -a source/"$d".
done
)
Если он автономный, скобки (... )
не нужны, поскольку они существуют только для локализации смены каталога.
Добавьте --delete
к rsync
, если вы хотите, чтобы файлы в месте назначения удалялись, когда их больше нет в источнике.