• Linux
  • April 2018
    M T W T F S S
    « Mar   May »
  • Meta

  • Follow me on Twitter

  • Advertisements

SyncAll script & SSH

I’ve been watching the EzeeLinux videos by Joe Collins at EzeeLinux.com and I’ve been learning a lot from them. I recently watched one in which he talked about a SyncAll script he wrote that uses rsync to synchronize a set of folders among all the computers in his home network. It occurred to me that our network environments were very similar so I reached out to him and asked for a copy of the script.

Modifying Joe’s script to fit my network and situation wasn’t all that difficult. One change I made to the script was to set a variable to hold the first three octets of the IP address so that if my networking environment changed for some reason (i.e., a new router) where it changed from 192.168.0.x to 192.168.1.x, I’d only have to make the change once in script.

It was by watching Mr. Desktop & Mr. Server Episode 5 | Linux Networking & Connect2SSH that it all came together for me. That video helped me to get SSH set up on my Linux computers so that the script would work properly. The video also introduced me to SCP (Secure Copy) and SSHFS (SSH File Share) which will prove to be very useful tools.

I’ve assigned static addresses to all of the wired connections, something I’d been thinking about doing for some time. I’ve still got a couple Windows PCs on the network but for now I can deal with them through SMB shares, Dropbox, or Sneaker-Net. If necessary, I could install Linux on the Windows box I just replaced and set up SAMBA on it.



5 Responses

  1. I got SSH keys set up on two of the laptops. After I set up the keys on the Latitude E5500 that I keep by the router, it gave me about not being able to find ~/rick/.pub whenever I tried to install the public key on the other machines.

    When I ran the ssh-copy-id command and specified the public key file, it would add the key to the authorized_keys file on each machine but I am still asked for a password.

    Just about everything I found on the topic was a bit over my level of expertise. For now, I can live with it since it’s not likely I’ll be running the SyncAll script from that laptop. If I do need to SSH into one of my computers from it, entering a password isn’t that big a deal. Still it would be nice to have it worked right.

    The errant machine is running LInux Mint 18.1 XFCE. I’ve got two other older laptops on which I’m planning to install Mint 18.3 XFCE. I’m wondering if I’ll run into the same problems with them.

  2. I added a function to the SyncIt script to display the correct syntax. It’s a little something I like to include in scripts that require arguments.

    I also modified a small script based on SyncIt to synchronize only by bin and network documentation folders. It’s important to me to have those folders up to date on all my Linux computers.

  3. Re: the ssh-copy-id problem.
    I upgraded the E5500 to Mint 18.3 but I didn’t expect that to resolve the problem. Today I installed Mint 18.3 on the Gateway laptop and once again, I was not able to copy it’s public key to any other machine. Is this an issue with Mint XFCE?

    It’s not like I’ll be using these XFCE machines a lot and if I do have to connect via SSH from them, I can still enter passwords. A bit inconvenient but I can live with it. I have been able to copy keys to these machines and I can connect to them without any problems.

  4. One of the things that bothered me in the SyncAll script was the use of ifconfig to get the source cmputer’s IP address since ifconfig has been deprecated in Ubuntu 16.04 and Linux Mint 18.x. After doing a bit of research I found that hostname -I | cut -f1 -d ‘ ‘ worked just as well and simplified the script.

  5. Many of the scripts I’ve recently adapted for my use require the last octet of the IP address. Joe’s scripts only provided an error message if there were no arguments or if the operation failed. Since the required argument is the last portion of the IP address, I wrote a nested if-statement to determine if the argument was an integer and, if it was, determine if it was in the range of potential valid IP addresses (1-254)

    Maybe I’m a little old school, but I learned to write well structured code with clear and concise comments, meaning full variable names, and useful error messages. If a program or a script is expecting a particular input then it needs to well defined and the program/script needs to check to ensure the input is correct. Perhaps because of that, my expectations for code are a bit high but there’s no excuse for sloppy code. Okay, end of rant.

Comments are closed.

%d bloggers like this: