diff --git a/bin/vps b/bin/vps index fcc3338..68993d4 100755 --- a/bin/vps +++ b/bin/vps @@ -230,11 +230,18 @@ mailcow:install-backup() { dest="$BACKUP_SERVER" dest="${dest%/*}" - dest="${dest%%:*}" - - info "You should add key on '$dest' host:" - echo compose-add-rsync-key -R "\"$DOMAIN\"" "\"$(cat /var/lib/rsync/.ssh/id_rsa.pub)\"" + ssh_options=() + if [[ "$dest" == *":"* ]]; then + port="${dest##*:}" + dest="${dest%%:*}" + ssh_options=(-p "$port") + else + port="" + dest="${dest%%:*}" + fi + info "You can run this following from an host having admin access to $dest:" + echo "ssh ${ssh_options[@]} rsync@$dest ssh-key add \"$(cat /var/lib/rsync/.ssh/id_rsa.pub)\"" } compose:install-backup() { @@ -302,10 +309,23 @@ $(e "$private_key" | sed -r 's/^/ /g') EOF fi - info "You can run this following command on $BACKUP_SERVER:" - public_key=$(ssh-keygen -y -f <(e "$private_key"$'\n')) - echo "compose-add-rsync-key -R '$host' '$public_key ${service_name}@$host'" + dest="$BACKUP_SERVER" + dest="${dest%/*}" + ssh_options=() + ssh_options=() + if [[ "$dest" == *":"* ]]; then + port="${dest##*:}" + dest="${dest%%:*}" + ssh_options=(-p "$port") + else + port="" + dest="${dest%%:*}" + fi + + info "You can run this following from an host having admin access to $dest:" + public_key=$(ssh-keygen -y -f <(e "$private_key"$'\n')) + echo "ssh ${ssh_options[@]} rsync@$dest ssh-key add '$public_key ${service_name}@$host'" }