After you have enabled 2FA for your GitHub account you must use either a personal access token or an SSH key instead of your password when accessing GitHub on the SCC command line.

Determine URL Type

First, determine which type of remote URLs you use on the SCC when you access your GitHub remote repos. Go to a directory where you have a repository on the SCC and execute the following lines:

module load git  
git remote -v

You should create a personal access token if you use HTTPS remote URLs and the output looks like this:

origin https://github.com/my_user_name/my_repo_name.git (fetch)
origin https://github.com/my_user_name/my_repo_name.git (push)

You should create SSH keys if you use SSH remote URLs and the output looks like this:

origin git@github.com:my_user_name/my_repo_name.git (fetch)
origin git@github.com:my_user_name/my_repo_name.git (push)

Change URL Type

You can change which type of URLs you use with the following command (you need to execute this command for each repository you want to modify the URL):

From ssh to https:

git remote set-url origin https://github.com/my_user_name/my_repo_name.git

From https to ssh:

git remote set-url origin git@github.com:my_user_name/my_repo_name.git

Setting Personal Access Token

GitHub Directions

  1. Login to GitHub. In the right upper corner click the arrow next to your avatar and select “Settings”:
    From the GitHub interface, users click the avatar in the top right corner. Then, select Settings from the dropdown menu.
  2. On the left sidebar select “Developer settings“. Select “Personal access tokens” and “Tokens (Classic)“on the left.
  3. Click the “Generate new token” button (GitHub might require you to enter your GitHub password):
    Click rectangle "Generate new token" button in top right of GitHub window.
  4. In the “Note” field give the token a description, i.e “SCC Access Token
  5. Select permissions for this token. The description of each permission can be found on GitHub Docs. For version control of your repositories it is enough to select “repo“, “admin:repo_hook“, and “delete repo“. Press the “Generate token” button on the bottom.
  6. Leave the page with the GitHub personal access token open.
  7. On any SCC node execute:
    username@scc1[~]$ git config --global credential.helper store

    This command will add the following line in your ~/.gitconfig file:

    [credential]
            helper = store
  8. Create a commit in any of your current SCC repositories and then push this commit to GitHub. You will be asked to enter your username and then your password. For the password copy your “personal access token” from the GitHub webpage. Note that you will NOT see any text you paste in the SCC command window. Once you have authenticated once, you will not be prompted to enter your credentials for this or any other repository on the SCC.Alternatively, you can manually generate a ~/.git-credentials file and store your personal access token there. This file should contain a single line:
    username@scc1[~]$ cat ~/.git-credentials
    https://your_github_user_name:your_personal_access_token@github.com

    Finally, ensure that this file is only accessible by you by setting the permissions accordingly:

    username@scc1[~]$ chmod 600 ~/.git-credentials

Authenticating on the command line using SSH

GitHub Directions

  1. First check if you already have existing SSH keys (execute on any SCC node):
    username@scc1[~]$ ls -al ~/.ssh

    If you see one of the following files, you already have an ssh key:

    id_rsa.pub
    id_ecdsa.pub
    id_ed25519.pub
  2. If you do not have ssh keys, you can use ssh-keygen to create one. The following command can be run from anywhere on the SCC.
    username@scc1[~]$ ssh-keygen -t ed25519 -C "username@bu.edu"

    When prompted to “Enter a file in which to save the key“, press Enter to accept the default location of the file. Next, when prompted to enter a passphrase, create a passphrase (if you do not want to enter any passphrase, just click Enter.)

  3. Now you should have a ~/.ssh/id_ed25519.pub file. You can check using the following command:
    username@scc1[~]$ ls -al ~/.ssh
  4. Login to GitHub. In the right upper corner click the arrow next to your avatar and select “Settings“:
    From the GitHub interface, users click the avatar in the top right corner. Then, select Settings from the dropdown menu.
  5. On the left sidebar select “SSH and GPG keys
  6. Click the “New SSH key” button
  7. In the title enter “SCC ssh key” (or any other descriptive title)
  8. Display the public ssh key you generated on the SCC (execute on the SCC):
    cat ~/.ssh/id_ed25519.pub
  9. Copy the content of the above file into the “Key” field of the GitHub webpage and then click “Add ssh key“.You should now be able to push and fetch your commits between the SCC and GitHub.