Skip to content

BASH Servers

BASH Servers

SSH stands for secure shell. It is used to run a server or network, securely. Often times, when working from your personal device, you will be asked to ssh to a remote server using the command line. This will allow for added security from the perspective of your company or team and the ability to share files easily amongst team members. You won’t be logging in to a server in this module. But, it is definitely useful to know for your future projects.

Logging in to a Remote Server

To log in to a remote server, you would carry out the following steps: 

  1. Open a terminal window
  2. Type in ssh server_name
  3. Change the default password using the passwd command followed by your new password

Upon logging in, your prompt will change slightly to indicate your new username.

e.g. When I SSH to a server provided by USC, my username changes from ramiyasivakumar to ramiyapr. This reminds me of the server I’m using.

A useful command is the hostname command. This will print the name of the server you are on.

Copying files to and from servers

There are many ways to get files over to a server. Some are no longer used, and each server has its own rules that are set by the sysadmin. If you are using a MacOS, then it too can be a server, and you can open up the ability to open it up to the world.  Some examples are telnet, scp, rsync, sftp, ftp and so forth.  There are graphical tools which can aid in this process, but for now, we will ignore them. We will focus on rsync.  We focus on rsync because scp only provides a cp like method to copy files from one machine to a remote machine over a secure SSH connection – and better, rsync,provides synchronization options to pick up where things left off.  rsync allows you to synchronize remote folders.

To copy a folder from your local device to the server, the syntax would look something like this:

rsync -azvh myfolder server_name:~

In this example, I am copying a folder called myfolder, to a server called server_name

The -azvh is an option I’m using.  To better understand what options are available,  you can look at the rsync manual, by typing man rsync though many web pages provide easier to understand options.