COMP0233 22-23
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Setting SSH keys to work with Github :::info generate the keys after you've set up your Github account. You will need to use one of the e-mail addresses you've registered on github. ::: ## Creating ssh keys You can generate the ssh keys in two ways. The easiest is [using Github CLI](#Using-Github-CLI-easy), the second way is [the classical way](#Classical). Both are done using the terminal. ### Using Github CLI (easy) This way requires the installation of the [GitHub's CLI](https://cli.github.com/). #### Installing GitHub's CLI :::spoiler Windows Proceed with the installer. ::: :::spoiler MacOS The easiest way is through [homebrew](https://brew.sh/). To install homebrew you need to: 1. Open a terminal window 1. Type ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` 1. Follow the installation prompts 1. Once homebrew is installed, you can then install Github's CLI ```bash brew install gh ``` ::: :::spoiler Linux Install [Github's CLI following the option according to your distribution](https://github.com/cli/cli#linux--bsd). ::: #### Generating the keys using Github's CLI 1. Open a terminal 1. Type: ```bash gh auth login ``` 1. Follow the prompt answering as: - log into: **GitHub.com** - Protocol: **SSH** - Generate SSH key: **Y** - passphrase: `<enter a new password for shh>` - Title: <kbd>Enter</kbd> (unless you want to change the default) - Authenticate: **Login with a web browser** 1. Insert the one-time code provided in the github page that it opens 1. Accept the permission request on the GitHub page. Now that we’ve set that up, let’s check our authentication again from the command line. ```bash ssh -T git@github.com Hi username! You've successfully authenticated, but GitHub does not provide shell access. ``` If you are asked somethig like: ``` Are you sure you want to continue connecting (yes/no/[fingerprint])? ``` Then you need to type `yes`. ### Classical Open a bash terminal (gitbash in windows) ```bash ls -al ~/.ssh ``` Your output is going to look a little different depending on whether or not SSH has ever been set up on the computer you are using. If you haven't set up SSH on this computer, you should get: ``` ls: cannot access '/c/Users/username/.ssh': No such file or directory ``` If SSH has been set up on the computer you’re using, the public and private key pairs will be listed. The file names are either id_ed25519/id_ed25519.pub or id_rsa/id_rsa.pub depending on how the key pairs were set up. If they don’t exist on your computer, you can proceed to create one (using the email from your github account) ```bash $ ssh-keygen -t ed25519 -C "your@email.com" ``` If you are using a legacy system that doesn’t support the Ed25519 algorithm, use: ```bash $ ssh-keygen -t rsa -b 4096 -C "your_email@example.com" ``` ```output Generating public/private ed25519 key pair. Enter file in which to save the key (/c/Users/username/.ssh/id_ed25519): ``` We want to use the default file, so press <kbd>Enter</kbd> to continue. ```output Created directory '/c/Users/username/.ssh'. Enter passphrase (empty for no passphrase): ``` Now, it is prompting you for a passphrase. You want to create a passphrase that's secure enough, but be sure to use something memorable or save your passphrase somewhere, as there is no “reset my password” option. ```output Enter same passphrase again: ``` After entering the same passphrase a second time, we receive the confirmation ```output Your identification has been saved in /c/Users/username/.ssh/id_ed25519 Your public key has been saved in /c/Users/username/.ssh/id_ed25519.pub The key fingerprint is: SHA256:SMSPIStNyA00KPxuYu94KpZgRAYjgt9g4BA4kFy3g1o your@email.com The key's randomart image is: +--[ED25519 256]--+ |^B== o. | |%*=.*.+ | |+=.E =.+ | | .=.+.o.. | |.... . S | |.+ o | |+ = | |.o.o | |oo+. | +----[SHA256]-----+ ``` The “identification” is actually the private key. You should never share it. The public key is appropriately named. The “key fingerprint” is a shorter version of a public key. Now that we have generated the SSH keys, we will find the SSH files when we check. ```bash ls -al ~/.ssh drwxr-xr-x 1 username 197121 0 Jul 16 14:48 ./ drwxr-xr-x 1 username 197121 0 Jul 16 14:48 ../ -rw-r--r-- 1 username 197121 419 Jul 16 14:48 id_ed25519 -rw-r--r-- 1 username 197121 106 Jul 16 14:48 id_ed25519.pub ``` Now we run the command to check if GitHub can read our authentication. ```bash ssh -T git@github.com The authenticity of host 'github.com (192.30.255.112)' can't be established. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? y Please type 'yes', 'no' or the fingerprint: yes Warning: Permanently added 'github.com' (RSA) to the list of known hosts. git@github.com: Permission denied (publickey). ``` Now, we need to copy the public key. Be sure to include the .pub at the end, otherwise you’re looking at the private key. ```bash cat ~/.ssh/id_ed25519.pub ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDmRA3d51X0uu9wXek559gfn6UFNF69yZjChyBIU2qKI a.linguini@ratatouille.fr ``` Now, going to GitHub.com, click on your profile icon in the top right corner to get the drop-down menu. Click “Settings,” then on the settings page, click “SSH and GPG keys,” on the left side “Account settings” menu. Click the “New SSH key” button on the right side. Now, you can add the title (You can use the title “My Laptop” or something that helps you to remember where the original key pair files are located), paste your SSH key into the field, and click the “Add SSH key” to complete the setup. Now that we’ve set that up, let’s check our authentication again from the command line. ```bash ssh -T git@github.com Hi username! You've successfully authenticated, but GitHub does not provide shell access. ``` ```bash eval $(ssh-agent) ssh-add ~/.ssh/id_ed25519 ``` ###### tags: `COMP0233` `teaching` `guides`

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully