-
Notifications
You must be signed in to change notification settings - Fork 7
Quickstart for github setup #213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,113 @@ | |
|
|
||
| How to's concerning `git` in general, [`gitlab`][cern_gitlab], [`github`][github] and CI. | ||
|
|
||
| ## Github Commandline Access Quickstart | ||
|
|
||
| This section explains the basic steps to get started with `github`. | ||
| Since a few years, github has disabled access via password only for security reasons, | ||
JoschD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| so you need to cre | ||
JoschD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| This aims to be as short and concise as possible, for more extenive information, [see the github security documentation][github_security]. | ||
JoschD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Setup SSH Access | ||
|
|
||
| An easy way to access github securely is to use SSH. | ||
|
|
||
| #### Create SSH Key | ||
|
|
||
| For this, you first need to create a SSH key pair on your computer using the email address of your github account. | ||
JoschD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```bash | ||
| ssh-keygen -t ed25519 -C "[email protected]" | ||
| ``` | ||
|
|
||
| When asked for a location, it make sense to give it an easily identifiable name, so you will know what the key is for. | ||
JoschD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| The file should be placed in `~/.ssh/`, unless you are on `afs`, in which case the `~/private/` directory should be used. | ||
fsoubelet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ```text | ||
| ~/.ssh/github_sshkey | ||
| ``` | ||
|
|
||
| This will create two files: `github_sshkey` and `github_sshkey.pub`. | ||
| The `.pub` is your public key that you can share with others, | ||
| while the other file is your private key and **should never be shared with anyone!** | ||
|
|
||
| !!! quote "Keep it secret, keep it safe!" | ||
| _Gandalf_, about private SSH keys (probably). | ||
|
|
||
| #### Add SSH Key to Github | ||
JoschD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| After creating the key, you need to add it to your github account. | ||
| For this you need to log into your github account, click on your avatar and go to `Settings` → `SSH and GPG keys`. | ||
JoschD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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. | ||
|
|
||
| Give it a resonable name in the `Title` field and leave the `Key type` as `Authentication key`. | ||
JoschD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Then click on `Add SSH key` and you are done. | ||
|
|
||
| #### Configure SSH to use the key | ||
|
|
||
| Next, you need to tell your local SSH client to use the key you created to connect to github. | ||
| For that, add the following lines to your `~/.ssh/config` file: | ||
JoschD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```bash | ||
| Host github.com | ||
| HostName github.com | ||
| User git | ||
| IdentityFile ~/.ssh/github_sshkey | ||
| ``` | ||
|
|
||
| or the path to your key you chose earlier. | ||
JoschD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| !!! warning "Username" | ||
| It is important that the `User` is `git` and **not your git-username**! | ||
| Github will identify you automatically based on the email address you used to create the SSH key. | ||
fsoubelet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| #### Test Access | ||
|
|
||
| Now you can test that everything works by running the following command: | ||
|
|
||
| ```bash | ||
| ssh -T github.com | ||
| ``` | ||
|
|
||
| which should then display | ||
|
|
||
| ```text | ||
| Hi <Username>! You've successfully authenticated, but GitHub does not provide shell access. | ||
| ``` | ||
|
|
||
| #### Clone Repository | ||
|
|
||
| When you clone a new repository, always use the SSH url | ||
|
|
||
| ```text | ||
| git clone [email protected]:pylhc/omc3.git | ||
| ``` | ||
|
|
||
| which you can find from the ++"Clone"++{.green-gui-button} button of the repository page on github. | ||
|
|
||
|
|
||
| !!! tip "Changing a Repository URL" | ||
| In case you already have a repository cloned with the wrong URL, you can change it with `git remote set-url`, e.g.: | ||
|
|
||
| ```bash | ||
| git remote set-url origin [email protected]:pylhc/omc3.git | ||
| ``` | ||
|
|
||
| If you are not sure which url is currently set, you can always check it with | ||
|
|
||
| ```bash | ||
| git remote -v | ||
| ``` | ||
|
|
||
| ### Setup HTTPS Access | ||
|
|
||
| You can setup https access by creating and using a personal access token or a password manager. | ||
|
|
||
| !!! note "Not yet documented" | ||
| As I am using SSH access, this is not yet documented. | ||
JoschD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Refer to the [github documentation][github_https] for more information and maybe write up a quick howto. | ||
|
|
||
|
|
||
| ## Configuring Gitlab CI to Automatically Pull into AFS | ||
|
|
||
| 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 | |
| *[CD]: Continuous Delivery | ||
| *[lxplus]: Linux Public Login User Service | ||
|
|
||
| [sshuttle]: https://sshuttle.readthedocs.io/en/stable/ | ||
| [new_account]: https://account.cern.ch/account/Management/NewAccount.aspx | ||
| [afs_services]: https://resources.web.cern.ch/resources/Manage/AFS/Default.aspx | ||
| [github]: https://github.com/ | ||
| [cern_gitlab]: https://gitlab.cern.ch/ | ||
| [cern_linux]: https://linux.web.cern.ch/dockerimages/ | ||
| [acc_models_repo]: https://gitlab.cern.ch/acc-models/acc-models-lhc/ | ||
| [acc_models_yml]: https://gitlab.cern.ch/acc-models/acc-models-lhc/-/blob/2018/.gitlab-ci.yml | ||
| [acc_models_docker]: https://gitlab.cern.ch/acc-models/acc-models-www/-/blob/master/_docker/Dockerfile_cern_cc7_base | ||
| [github_security]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure | ||
| [github_https]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/about-authentication-to-github#https | ||
| [github_ssh]: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh | ||
| [github_new_ssh_key]: https://github.com/settings/ssh/new | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.