Remote File Management with
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:
- Create an ssh key-pair by running:
$ ssh-keygenand 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/id_rsa.pub. 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=+++++ | +----[SHA256]-----+ jejemplo@rms:~$
- Copy your ssh public key to
$ ssh-copy-id students.gctaa.netYou should now be able to ssh into the student web server without entering your password.
- Use the scp command to copy your
public_htmldirectory to your local machine by running the following command at the bash prompt from your home directory:
$ scp -r students.gctaa.net:public_html .Note that the dot (
.) at the end of the command is an essential part of it.
- 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_aliasesin your home directory and put the following in it:
alias c2stds="rsync -avz --delete $HOME/public_html students.gctaa.net:" alias s2local="rsync -avz --delete students.gctaa.net:public_html/ $HOME/public_html"Then run this script from your bash prompt in your home directory with:
$ . .bash_aliasesYou should now be able to run:
$ c2stdsfrom the bash prompt any time you want to copy your local changes to the student server.