Remote File Management with scp and rsync

Our goal is to be able to work on a local machine in our CS / IT Web lab and easily synchronize your work with our student web server.

Do all of the following to set this up:

  1. Create an ssh key-pair by running:
    $ ssh-keygen
    and then hitting enter (note: don't set a password) until you see something like this:
    jejemplo@rms:~$ ssh-keygen 
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/jejemplo/.ssh/id_rsa): 
    Created directory '/home/jejemplo/.ssh'.
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /home/jejemplo/.ssh/id_rsa.
    Your public key has been saved in /home/jejemplo/.ssh/
    The key fingerprint is:
    SHA256:Al4e2lyafPJibI+qPO/v5yzhSU1BhiBjng+jjPz1kHg jejemplo@rms
    The key's randomart image is:
    +---[RSA 2048]----+
    |  + .. oo        |
    | o +  ...        |
    |  = . o ..       |
    |+. =.O.=.        |
    |oo .+EXoS        |
    |  . o.==.        |
    |   . o=+.        |
    | ..  o+=.        |
    |  o=+++++        |
  2. Copy your ssh public key to with:
    $ ssh-copy-id
    You should now be able to ssh into the student web server without entering your password.
  3. Use the scp command to copy your public_html directory to your local machine by running the following command at the bash prompt from your home directory:
    $ scp -r .
    Note that the dot (.) at the end of the command is an essential part of it.
  4. Now add a bash alias for running rsync to synchronize changes you make on your local machine with the student server. Edit a file named .bash_aliases in your home directory and put the following in it:
    alias c2stds="rsync -avz --delete $HOME/public_html"
    alias s2local="rsync -avz --delete $HOME/public_html"
    Then run this script from your bash prompt in your home directory with:
    $ . .bash_aliases
    You should now be able to run:
    $ c2stds
    from the bash prompt any time you want to copy your local changes to the student server.