Skip to content

Commit f3e921d

Browse files
committed
added quickstart
1 parent 452f581 commit f3e921d

File tree

1 file changed

+111
-5
lines changed

1 file changed

+111
-5
lines changed

docs/resources/git_setup.md

Lines changed: 111 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,113 @@
22

33
How to's concerning `git` in general, [`gitlab`][cern_gitlab], [`github`][github] and CI.
44

5+
## Github Commandline Access Quickstart
6+
7+
This section explains the basic steps to get started with `github`.
8+
Since a few years, github has disabled access via password only for security reasons,
9+
so you need to cre
10+
This aims to be as short and concise as possible, for more extenive information, [see the github security documentation][github_security].
11+
12+
## Setup SSH Access
13+
14+
An easy way to access github securely is to use SSH.
15+
16+
### Create SSH Key
17+
18+
For this, you first need to create a SSH key pair on your computer using the email address of your github account.
19+
20+
```bash
21+
ssh-keygen -t ed25519 -C "[email protected]"
22+
```
23+
24+
When asked for a location, it make sense to give it an easily identifiable name, so you will know what the key is for.
25+
The file should be placed in `~/.ssh/`, unless you are on `afs`, in which case the `~/private/` directory should be used.
26+
27+
```text
28+
~/.ssh/github_sshkey
29+
```
30+
31+
This will create two files: `github_sshkey` and `github_sshkey.pub`.
32+
The `.pub` is your public key that you can share with others,
33+
while the other file is your private key and **should never be shared with anyone!**
34+
35+
!!! quote "Keep it secret, keep it safe!"
36+
_Gandalf_, about private SSH keys (probably).
37+
38+
### Add SSH Key to Github
39+
40+
After creating the key, you need to add it to your github account.
41+
For this you need to log into your github account, click on your avatar and go to `Settings` → `SSH and GPG keys`.
42+
Then click on [++"New SSH key"++{.green-gui-button}][github_new_ssh_key]{target=_blank} and paste the contents of the `.pub` file into the `Key` field.
43+
44+
Give it a resonable name in the `Title` field and leave the `Key type` as `Authentication key`.
45+
Then click on `Add SSH key` and you are done.
46+
47+
### Configure SSH to use the key
48+
49+
Next, you need to tell your local SSH client to use the key you created to connect to github.
50+
For that, add the following lines to your `~/.ssh/config` file:
51+
52+
```bash
53+
Host github.com
54+
HostName github.com
55+
User git
56+
IdentityFile ~/.ssh/github_sshkey
57+
```
58+
59+
or the path to your key you chose earlier.
60+
61+
!!! warning "Username"
62+
It is important that the `User` is `git` and **not your git-username**!
63+
Github will identify you automatically based on the email address you used to create the SSH key.
64+
65+
### Test Access
66+
67+
Now you can test that everything works by running the following command:
68+
69+
```bash
70+
ssh -T github.com
71+
```
72+
73+
which should then display
74+
75+
```text
76+
Hi <Username>! You've successfully authenticated, but GitHub does not provide shell access.
77+
```
78+
79+
### Clone Repository
80+
81+
When you clone a new repository, always use the SSH url
82+
83+
```text
84+
git clone [email protected]:pylhc/omc3.git
85+
```
86+
87+
which you can find from the ++"Clone"++{.green-gui-button} button of the repository page on github.
88+
89+
90+
!!! tip "Changing a Repository URL"
91+
In case you already have a repository cloned with the wrong URL, you can change it with `git remote set-url`, e.g.:
92+
93+
```bash
94+
git remote set-url origin [email protected]:pylhc/omc3.git
95+
```
96+
97+
If you are not sure which url is currently set, you can always check it with
98+
99+
```bash
100+
git remote -v
101+
```
102+
103+
## Setup HTTPS Access
104+
105+
You can setup https access by creating and using a personal access token or a password manager.
106+
107+
!!! note "Not yet documented"
108+
As I am using SSH access, this is not yet documented.
109+
Refer to the [github documentation][github_https] for more information and maybe write up a quick howto.
110+
111+
5112
## Configuring Gitlab CI to Automatically Pull into AFS
6113

7114
If you are programming locally, but also want to have a copy on AFS, either because your colleges are not comfortable with Gitlab or you need the code for other scripts that you are running on lxplus or similar, here is how:
@@ -120,12 +227,11 @@ Whenever you are pushing now any commits to the `master` branch, the CI/CD will
120227
*[CD]: Continuous Delivery
121228
*[lxplus]: Linux Public Login User Service
122229

123-
[sshuttle]: https://sshuttle.readthedocs.io/en/stable/
124230
[new_account]: https://account.cern.ch/account/Management/NewAccount.aspx
125231
[afs_services]: https://resources.web.cern.ch/resources/Manage/AFS/Default.aspx
126232
[github]: https://github.com/
127233
[cern_gitlab]: https://gitlab.cern.ch/
128-
[cern_linux]: https://linux.web.cern.ch/dockerimages/
129-
[acc_models_repo]: https://gitlab.cern.ch/acc-models/acc-models-lhc/
130-
[acc_models_yml]: https://gitlab.cern.ch/acc-models/acc-models-lhc/-/blob/2018/.gitlab-ci.yml
131-
[acc_models_docker]: https://gitlab.cern.ch/acc-models/acc-models-www/-/blob/master/_docker/Dockerfile_cern_cc7_base
234+
[github_security]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure
235+
[github_https]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/about-authentication-to-github#https
236+
[github_ssh]: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh
237+
[github_new_ssh_key]: https://github.com/settings/ssh/new

0 commit comments

Comments
 (0)