Musica Informatica Elettronica Web Foto Video

Backup client ubuntu su Server debian


Warning: Illegal string offset 'lang' in /web/htdocs/www.marcodevivo.com/home/wp-content/plugins/wp-highlightjs/wp_highlight.js.php on line 119

Warning: Illegal string offset 'lang' in /web/htdocs/www.marcodevivo.com/home/wp-content/plugins/wp-highlightjs/wp_highlight.js.php on line 119

Warning: Illegal string offset 'lang' in /web/htdocs/www.marcodevivo.com/home/wp-content/plugins/wp-highlightjs/wp_highlight.js.php on line 119

Warning: Illegal string offset 'lang' in /web/htdocs/www.marcodevivo.com/home/wp-content/plugins/wp-highlightjs/wp_highlight.js.php on line 119

Warning: Illegal string offset 'lang' in /web/htdocs/www.marcodevivo.com/home/wp-content/plugins/wp-highlightjs/wp_highlight.js.php on line 119

Warning: Illegal string offset 'lang' in /web/htdocs/www.marcodevivo.com/home/wp-content/plugins/wp-highlightjs/wp_highlight.js.php on line 119

Warning: Illegal string offset 'lang' in /web/htdocs/www.marcodevivo.com/home/wp-content/plugins/wp-highlightjs/wp_highlight.js.php on line 119

Warning: Illegal string offset 'lang' in /web/htdocs/www.marcodevivo.com/home/wp-content/plugins/wp-highlightjs/wp_highlight.js.php on line 119

Warning: Illegal string offset 'lang' in /web/htdocs/www.marcodevivo.com/home/wp-content/plugins/wp-highlightjs/wp_highlight.js.php on line 119

Warning: Illegal string offset 'lang' in /web/htdocs/www.marcodevivo.com/home/wp-content/plugins/wp-highlightjs/wp_highlight.js.php on line 119
Share Button

Server

creare utente

adduser nomeutente

creare cartella .ssh e settare i permessi
mkdir /home/nomeutente/.ssh
chmod 755 /home/nomeutente/.ssh

creare file authorized_keys e settare i permessi
touch /home/nomeutente/.ssh/authorized_keys
chmod 644 /home/nomeutente/.ssh/authorized_keys
chown -R nomeutente:nomeutente /home/nomeutente/.ssh

opzionale
creare spazio di backup su disco grande montato su /data
mkdir -p /data/backup/nomeutente
chmod 755 /data/backup/nomeutente
chown -R nomeutente:nomeutente /data/backup/nomeutente

creare link simbolico in caso di backup su /data. altrimenti creare cartella backup.
cd /home/nomeutente
ln -s /data/backup/nomeutente backup

 

Client

creare chiave ssh

ssh-keygen

copiare la chiave pubblica sul server
ssh-copy-id -i ~/.ssh/id_rsa.pub nomeutente@server_ip

in caso di porta differente dalla 22 utilizzare scp
scp -P <porta> ~/.ssh/id_rsa.pub nomeutente@server_ip:~/.ssh/authorized_keys

editare crontab
0 */3 * * * nomeutente rsync -az -e "ssh -p xx" \
--exclude=".*" --delete --force /home/nomeutente/ \
nomeutente@server_ip:/home/nomeutente/backup

*/3 #backup ogni 3 ore
-e "ssh -p xx" #in caso di porta diversa da 22
--exclude=".*" #non copia i file nascosti

 

Limitare a rsync i comandi autorizzati sul server

editare il file /home/nomeutente/.ssh/authorized_keys

command="/home/nomeutente/restricted-command",\
no-port-forwarding,no-X11-forwarding,no-agent-forwarding,\
no-pty ssh-rsa xxxxxxxxxxxxxx...xxxxxxx nomeutente@client

creare il file /home/nomeutente/restricted-command

#!/bin/sh

set $SSH_ORIGINAL_COMMAND

case "$1" in
   rsync)
     ;;
   *)
     logger -s -t restricted-command -- "Invalid command $@"
     exit 1
     ;;
esac

logger -t restricted-command -- "Executing $@"

exec "$@"

renderlo eseguibile

chmod 744 /home/nomeutente/restricted-command