gravity-sync
gravity-sync copied to clipboard
Gravity Sync 4.0.4 - Install with Custom SSH Port
I am trying to install Gravity Sync (latest version) and use a different SSH port. I have tried running export GS_SSH_PORT='2222' && curl -sSL https://gravity.vmstan.com | bash and just running curl -sSL https://gravity.vmstan.com | bash to no avail.
Both time out on connecting to the remote host to (I presume) add the SSH Key and verify Pi-Hole is installed; obviously because it is trying over Port 22.
Failed Install Output
โ ~ curl -sSL https://gravity.vmstan.com | bash
โ Gravity Sync Installation Script
ยป Validating User Permissions
โ Sudo utility detected
โ osadmin has sudo powers
ยป Validating Install of Required Components
โ SSH has been detected
โ GIT has been detected
โ RSYNC has been detected
โ Systemctl has been detected
ยป Performing Warp Core Diagnostics
โ Local installation of Pi-hole has been detected
ยป Executing Gravity Sync Deployment
โ Cleaning up bash.bashrc
You may need to exit your terminal or reboot before running 'gravity-sync' commands
โ Creating Gravity Sync Directories
Cloning into '/etc/gravity-sync/.gs'...
remote: Enumerating objects: 2775, done.
remote: Counting objects: 100% (220/220), done.
remote: Compressing objects: 100% (128/128), done.
remote: Total 2775 (delta 169), reused 94 (delta 90), pack-reused 2555
Receiving objects: 100% (2775/2775), 606.50 KiB | 5.18 MiB/s, done.
Resolving deltas: 100% (1774/1774), done.
โ Starting Gravity Sync Configuration
โ Initializing Gravity Sync (4.0.4)
โ Evaluating arguments: CONFIGURE
โ Creating new gravity-sync.conf
Welcome to the Gravity Sync Configuration Wizard
Please read through https://github.com/vmstan/gravity-sync/wiki before you continue
Make sure that Pi-hole is running on this system before your configure Gravity Sync
ยป Gravity Sync Remote Host Settings
โบ Remote Pi-hole host address
? IP: 192.168.7.21
โ Saving 192.168.7.21 host to gravity-sync.conf
โบ Remote Pi-hole host username
? User: osadmin
โ Saving [email protected] to gravity-sync.conf
ยป Gravity Sync SSH Key Settings
โ Generating new SSH key
โ Moving private key to /etc/gravity-sync/gravity-sync.rsa
โ Moving public key to /etc/gravity-sync/gravity-sync.rsa.pub
โ Loading gravity-sync.conf
โบ Registering SSH key to 192.168.7.21
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/etc/gravity-sync/gravity-sync.rsa.pub"
ssh: connect to host 192.168.7.21 port 22: Connection timed out
โ SSH key registered to 192.168.7.21
ยป Pi-hole Installation Settings
โ Detecting local Pi-hole installation
โ Default install of Pi-hole detected
โ Detecting remote Pi-hole installationssh: connect to host 192.168.7.21 port 22: Connection timed out
โ Detecting remote Pi-hole installation
Configuration has been completed successfully, once Gravity Sync has been installed your other
node, your next step is to push all of the of data from the currently authoritative
Pi-hole instance to the other.
ex: gravity-sync push
If that completes successfully you can automate future sync jobs to run at a regular interval on
both of your Gravity Sync peers.
ex: gravity-sync auto
โ Gravity Sync CONFIGURE completed after 664 seconds
So, I wait for install to timeout and fail and run gravity-sync config 2222 and it also fails:
Failed gravity-sync config output
โ ~ gravity-sync config 2222
โ Initializing Gravity Sync (4.0.4)
โ Evaluating arguments: CONFIGURE
! TARGET HOST SSH PORT SET TO 2222
! gravity-sync.conf already exists
โบ Proceeding will replace your existing configuration
? Type EJECT THE WARP CORE to confirm: EJECT THE WARP CORE
โ Erasing existing gravity-sync.conf
โ Creating new gravity-sync.conf
Welcome to the Gravity Sync Configuration Wizard
Please read through https://github.com/vmstan/gravity-sync/wiki before you continue
Make sure that Pi-hole is running on this system before your configure Gravity Sync
ยป Gravity Sync Remote Host Settings
โบ Remote Pi-hole host address
? IP: 192.168.7.21
โ Saving 192.168.7.21 host to gravity-sync.conf
โบ Remote Pi-hole host username
? User: osadmin
โ Saving [email protected] to gravity-sync.conf
ยป Gravity Sync SSH Key Settings
โ Using existing SSH key
โ Saving custom SSH port to gravity-sync.confH port to gravity-sync.conf
โ Saving custom SSH port to gravity-sync.conf
โบ Registering SSH key to 192.168.7.21
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/etc/gravity-sync/gravity-sync.rsa.pub"
[email protected]: Permission denied (publickey).
โ SSH key registered to 192.168.7.21
ยป Pi-hole Installation Settings
โ Detecting local Pi-hole installation
โ Default install of Pi-hole detected
โ Detecting remote Pi-hole [email protected]: Permission denied (publickey).
โ Detecting remote Pi-hole installation
Configuration has been completed successfully, once Gravity Sync has been installed your other
node, your next step is to push all of the of data from the currently authoritative
Pi-hole instance to the other.
ex: gravity-sync push
If that completes successfully you can automate future sync jobs to run at a regular interval on
both of your Gravity Sync peers.
ex: gravity-sync auto
โ Gravity Sync CONFIGURE completed after 13 seconds
Looking through this, it seems to be because the public SSH key is not getting pushed to the secondary server:
โ Detecting remote Pi-hole [email protected]: Permission denied (publickey).
So, I manually add /etc/gravity-sync/gravity-sync.rsa.pub to the remote host and vice versa:
more /etc/gravity-sync/gravity-sync.rsa.pub
<ssh key>
SSH into remote host and add key and confirm it is there
echo '<ssh key>' >> ~/.ssh/authorized_keys
more ~/.ssh/authorized_keys
I re-run gravity-sync config 2222 and it states successful
Successful gravity-sync config output
โ ~ gravity-sync config 2222
โ Initializing Gravity Sync (4.0.4)
โ Evaluating arguments: CONFIGURE
! TARGET HOST SSH PORT SET TO 2222
! gravity-sync.conf already exists
โบ Proceeding will replace your existing configuration
? Type FIRE ALL PHASERS to confirm: FIRE ALL PHASERS
โ Erasing existing gravity-sync.conf
โ Creating new gravity-sync.conf
Welcome to the Gravity Sync Configuration Wizard
Please read through https://github.com/vmstan/gravity-sync/wiki before you continue
Make sure that Pi-hole is running on this system before your configure Gravity Sync
ยป Gravity Sync Remote Host Settings
โบ Remote Pi-hole host address
? IP: 192.168.7.21
โ Saving 192.168.7.21 host to gravity-sync.conf
โบ Remote Pi-hole host username
? User: osadmin
โ Saving [email protected] to gravity-sync.conf
ยป Gravity Sync SSH Key Settings
โ Using existing SSH key
โ Saving custom SSH port to gravity-sync.confH port to gravity-sync.conf
โ Saving custom SSH port to gravity-sync.conf
โบ Registering SSH key to 192.168.7.21
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/etc/gravity-sync/gravity-sync.rsa.pub"
[email protected]: Permission denied (publickey).
โ SSH key registered to 192.168.7.21
ยป Pi-hole Installation Settings
โ Detecting local Pi-hole installation
โ Default install of Pi-hole detected
โ Detecting remote Pi-hole installation
โ Remote install of Pi-hole detected
Configuration has been completed successfully, once Gravity Sync has been installed your other
node, your next step is to push all of the of data from the currently authoritative
Pi-hole instance to the other.
ex: gravity-sync push
If that completes successfully you can automate future sync jobs to run at a regular interval on
both of your Gravity Sync peers.
ex: gravity-sync auto
โ Gravity Sync CONFIGURE completed after 11 seconds
I attempt to run gravity-sync push from the secondary device and it fails
gravity-sync push fail output
โ ~ gravity-sync push
โ Initializing Gravity Sync (4.0.4)
โ Loading gravity-sync.conf
โ Detecting local Pi-hole installation
โ Detecting remote Pi-hole installation
โ Gravity Sync remote peer is configured
โ Evaluating arguments ROOT
! osadmin has insufficient user rights for Gravity Sync
โ Gravity Sync ROOT exited after 1 seconds
Even though the installer verified the user had sufficient permissions, per https://github.com/vmstan/gravity-sync/issues/324#issuecomment-1097048032 I run sudo usermod -aG sudo osadmin on both devices and re-run gravity-sync push and it is successful.
Successful gravity-sync push
โ ~ gravity-sync push
โ Initializing Gravity Sync (4.0.4)
โ Loading gravity-sync.conf
โ Detecting local Pi-hole installation
โ Detecting remote Pi-hole installation
โ Gravity Sync remote peer is configured
โ Evaluating arguments: PUSH
ยป Remote target [email protected]:2222
โ Validating pathways to Pi-hole
โ Validating pathways to DNSMASQ
โ Hashing the remote Gravity Database
โ Comparing to the local Gravity Database
! Differences detected in the Gravity Database
โ Hashing the remote DNS Records
โ Comparing to the local DNS Records
! Differences detected in the DNS Records
! DNS CNAMEs not detected on the local Pi-hole
! Static DHCP Addresses not detected on the local Pi-hole
! Replication of Pi-hole settings is required
โ Performing backup of remote Gravity Database
โ Performing backup of local Gravity Database
โ Checking Gravity Database copy integrity
โ Pushing the local Gravity Database
โ Setting file ownership on Gravity Database
โ Setting file permissions on Gravity Database
โ Performing backup of remote DNS Records
โ Performing backup of local DNS Records
โ Pushing the local DNS Records
โ Setting file ownership on DNS Records
โ Setting file permissions on DNS Records
โ Updating remote FTLDNS configuration
โ Reloading remote FTLDNS services
โบ Performing replicator diagnostics
โ Rehashing the remote Gravity Database
โ Recomparing to local Gravity Database
โ Rehashing the remote DNS Records
โ Recomparing to local DNS Records
! DNS CNAMEs not detected on the local Pi-hole
! Static DHCP Addresses not detected on the local Pi-hole
โ Saving updated data hashes
โ Sending hashes to Gravity Sync peer
โ Setting permissions on remote hashing files
โ Logging successful PUSH
โ Gravity Sync PUSH completed after 28 seconds
So, my question is: Is this a defect or am I doing something wrong? Thank you!
I figured this error out:
โ Detecting remote Pi-hole [email protected]: Permission denied (publickey).
I have PasswordAuthentication set to no in my SSH config /etc/ssh/sshd_config. Gravity Sync uses ssh-copy-id to copy over the Public Key and to do so, requires PasswordAuthentication to be set to yes (which makes sense).
It would be nice to do a check to see if PasswordAuthentication is off and, if so, present the user with the option to manually add the public key to the remote host and then come back and press any key to continue. Don't know if you accept PRs for this, happy to try and add the logic.
Other issues still remain:
- Still digging through to see if its possible for me to specify the SSH port on initial install so I don't have to wait for it to error out just to run
gravity-sync config 2222. - With regards to
sudo usermod -aG sudo osadmin, I will try to mimic and reproduce this issue
I have submitted this PR https://github.com/vmstan/gs-install/pull/4 to add the ability to specify a custom SSH port on install.
Effective July 26, 2024, this project has been retired. Thank you for your use and enthusiasm for a project that began as a few lines of bash in a Slack channel and envolved into something far more complex, and used by many thousands of Pi-hole enthusiasts over the last four years.