This tutorial is for Mac users. For Windows users, please first read the tutorial to install Git for Windows, which ships with Git Bash, then most bash commands in this tutorial will work in Git Bash.

Connect from your Mac to teaching server

  1. SSH client on MacOS.

    • MacOS: open the Terminal app. You can find Terminal from LaunchPad -> Other, or from Spotlight Search (type Terminal). For convenience, you can pin the Terminal program to the Dock.
    • Check that current shell is Bash
    echo $SHELL
    • If necessary, change default shell to Bash by following command in Terminal. Then close the Terminal window and reopen it.
    chsh -s /bin/bash
  2. Connect to the teaching server. On MacOS Terminal:

    ssh [USERNAME]@server.ucla-biostat-203b.com

    Replace [USERNAME] in the command by your actual user name (your email name in MyUCLA). If you cannot connect, you may not have an account. Ask TA or instructor for help.

  3. Change password on teaching server

    passwd
  4. You can use git to obtain a copy of course materials:

    git clone https://github.com/ucla-biostat-203b/2022winter.git

Install R and RStudio on your own machine.

  1. Install R v4.1.2 or later. https://cran.rstudio.com

  2. Install RStudio Desktop (Open Source Edition). https://rstudio.com/products/rstudio/#Desktop

Git

Check whether git command is available in Terminal. If not, follow instructions at https://git-scm.com/book/en/v2/Getting-Started-Installing-Git Installing on macOS section to install it.

git clone and git pull course materials

  1. On whichever machine that has git installed, e.g., your Mac Terminal or teaching server, you can obtain the 203B course material by command
git clone https://github.com/ucla-biostat-203b/2022winter.git [<dir>]

Replace [<dir>] by your preferred folder name, say 203b-2022winter.

  1. The Git repository https://github.com/ucla-biostat-203b/2022winter.git is frequently updated. To sync your git clone with the current repo., first enter your local repo directory
cd /PATH/TO/LOCAL/REPO

then

git pull

If you have made commits to the local repo, then the two commits need to be merged.

  1. Besides command line, we can also use RStudio to perform git clone and many other git operations. To git clone a repository, in RStudio File -> New Project... -> Version Control -> Git, then copy the git address (not HTTPS address) git@github.com:ucla-biostat-203b/2022winter.git to the Repository URL:.

Access RStudio on the teaching server

Open your browser and enter address http://server.ucla-biostat-203b.com:8787 to use RStudio on the teaching server. Log in using your credential for the teaching server.

SSH keys

  1. First check whether you already have keys on your local machine.
ls -al ~/.ssh

If you donโ€™t have ~/.ssh folder, that means you have never used SSH before.

  1. If no SSH keys yet, generate a pair of SSH RSA keys
    • Method 1: generate keys on MacOS Terminal or Windows Git Bash. Follow instructions in lecture notes.
    • Method 2: Use RStudio to generate keys. Tools -> Global Options... -> Git/SVN. Using either method, make sure keys are in the default location ~/.ssh/
  2. Make sure the permission for the key files are correct.
    • On MacOS terminal:
      • The permission for the ~/.ssh folder should be 700 (drwx------).
      • The permission for the private key ~/.ssh/id_rsa should be 600 (-rw-------).
      • The permission of the public key ~/.ssh/id_rsa.pub should be 644 (-rw-r--r--).
    • On Window Git Bash, the following permission could also work:
      • The permission for the ~/.ssh folder can be 755 (drwxr-xr-x).
      • The permission for the private key ~/.ssh/id_rsa can be 644 (-rw-r--r--).
      • The permission of the public key ~/.ssh/id_rsa.pub can be 644 (-rw-r--r--).
  3. On the teaching server, put the same pair of keys under ~/.ssh.
    • The permission for the ~/.ssh folder should be 700 (drwx------).
    • The permission for the private key ~/.ssh/id_rsa should be 600 (-rw-------).
    • The permission of the public key ~/.ssh/id_rsa.pub should be 644 (-rw-r--r--).
    • The authorized_keys file should contain the public key (cannot duplicate) and its permission should be 600 (-rw-------).
  4. Now try to SSH into the teaching server from your Mac. If keys are set up correctly, you should be able to connect to the teaching server without entering password.
ssh [USERNAME]@server.ucla-biostat-203b.com