Mac Users | Windows Users |
---|---|
Open your terminal | open the Git Bash terminal |
In your terminal, run the following command:
Mac Users |
---|
ssh-keygen -t ed25519 -C "<your_email_address>"
Windows Users |
---|
cd ~
cd /c/Users/<username>/.ssh
ssh-keygen -t ed25519 -C "<your_email_address>"
You’ll see a response similar to:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_ed25519):<press ENTER>
PRESS ENTER and just accept the suggested file and directory.
**Press ENTER again to leave the passphrase empty. DO NOT ENTER A PASSPHRASE
**Press ENTER again to confirm an EMPTY PASSPHRASE.
If successful, you’ll see confirmation of where the ssh-keygen command saved your identification and private key.
To confirm and view existing SSH keys on your machine, run the command :
Run the following command:
ls -al ~/.ssh
You should see something similar like the image below: (Above are the SSH Keys on my laptop - YOUR FILE NAMES ARE NOT GOING TO BE THE SAME )
We will copy our public SSH key to a location that saves information in text format.
In your terminal, run the following command:
Mac Users |
---|
pbcopy < ~/.ssh/id_ed25519.pub
Windows Users |
---|
cat id_ed25519.pub | clip
YOU WILL NOT SEE ANYTHING HAPPENING AT THE TERMINAL
**But at this time the contents of the SSH key are in memory in the clipboard and we are ready to add it to GitLab **
Open Google Chrome (or browser you use),
-
Navigate to http://gitlab.com and sign in.
-
Select your avatar in the upper right corner, and click Settings
-
Menu on the left, Click SSH Keys
-
Paste the key that you copied into the Key text box.
-
Make sure your key includes a descriptive name in the Title text box, such as Work Laptop or Home Workstation.
-
Click the Add key button.
See image below on how to paste the key into the text box:
Mac Users | Windows Users |
---|---|
Cmd+V | Ctrl+V |
You should now be able to clone the class repo, and perform git pull to fetch new data into your computer.
Getting the <repo_url>:
- you will need to login to GitLab,
- navigate to Projects
- Click the "RU-HOU-PROJECT-NAME"
- Click the blue button "Clone", and copy the SSH URL
Now back to the terminal, we will clone the repository for the first time to a dedicated directory:
Both Mac & Windows |
---|
We will create a directory inside our Documents folder called "DATABOOTCAMP-MATERIAL" (you can change the name if you'd like), and inside that folder we will clone the class repository.
cd ~
cd Documents
mkdir <DATABOOTCAMP-MATERIAL>
cd <DATABOOTCAMP-MATERIAL>
git clone <repo_url_link>
Gitlab "READ MORE : How to clone a repository documentation"
To pull/fetch new data to your local computer, navigate to the folder location we specified above:
cd Documents/<DATABOOTCAMP-MATERIAL>/<ru-hou-some-long-folder-name>
git pull
|
NOTE: You will need to remember the passphrase you created for your ssh key. If you've accidentally created a passphrase for a git SSH key that requires you to type it for each git pull and git push you can just reset the password to blank by following this next sequence.
For Mac |
---|
ssh-keygen -p -f <ssh_key_filename>
For Windows |
---|
### Make sure to navigate to the folder location where the ssh keys are stored in your PC
cd /c/Users/<username>/.ssh
### then view the list of files on the .ssh folder
ls -la
### Once you know the filename for the SSH key you created with a passphrase and
### it is the one you added to Gitlab, you can run the following command:
ssh-keygen -p -f <ssh_key_filename>
Enter file in which the key is (/home/username/.ssh/<ssh_key_filename>): press Enter
Enter old passphrase: <old_passphrase>
Enter new passphrase (empty for no passphrase): <press_enter_to_leave_empty>
Enter same passphrase again: <press_enter_to_leave_empty>
You should now see a response like: Your identification has been saved with the new passphrase.
DONE!
You should now be ready to perform git push or git pull from GitLab without being asked for a passphrase every time!