Bernice1357689
    • Create new note
    • Create a note from template
      • 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
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me 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
    • Save as template
    • 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 Create Help
Create Create new note Create a note from template
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
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me 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
    # 在 Github 上使用 SSH key push 靜態網頁+展示 ###### tags:`Github`,`架站` --- [TOC] --- ## 前言 由於 Github 從 2021/08/13 開始停止提供輸入帳密的服務,所以現在只能用 SSH 金鑰了 QQ 再加上看到網路上的教學似乎都有點舊了,就來重寫一個 - ## 建立 SSH key ### 1. cd 到想要上傳到 Github的資料夾 ``` ssh-keygen -t rsa -b 4096 -C "your_email@example.com" ``` 打了這行後,就會出現這些: ``` Generating public/private rsa key pair. Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter] Enter passphrase (empty for no passphrase): [Type a passphrase] Enter same passphrase again: [Type passphrase again] ``` 簡單一點的話,3 個問題可以全部都按Enter跳過~ 接著,再繼續往下打 3 個指令 ### 2. 開啟 ssh-agent ``` eval "$(ssh-agent -s)" ``` ### 3. 將私鑰加入到 ssh-agent ``` ssh-add -K ~/.ssh/id_rsa ``` ### 4. 上傳公鑰 在 .ssh/ 資料夾下會分別有 id_rsa、id_rsa.pub 這兩個檔案,也就分別代表私鑰及公鑰,這一個步驟就是將 id_rsa.pub 也就是公鑰上傳到 Github 上。 ``` cat ~/.ssh/id_rsa.pub ``` 會出現一大串英文跟數字夾雜的公鑰,由 ssh-rsa開頭,自己的 email 結尾。接著就把整串都複製下來。 到 Github 網站,點選==Settings -> SSH and GPG keys -> New SSH Key==,把剛剛複製的一大串內容都貼上去,上面的標題可以自訂一個名稱,這樣就完成了! 這樣之後就不用再輸入帳密也能 push 檔案了~ ## 建立新的 repository :::info 這裡其實有兩種方法可以建立 repository,那我比較懶只介紹使用過的方法,想看另一種方法可以參考[這裡](https://eudora.cc/posts/45315/) ::: ### 1. 建立名為 username.github.io 的 repository 步驟: 打開 Github -> 點選右上角的頭像 -> Your repositories -> 右上角綠綠的 New 點下去之後,就會進入以下畫面 ![](https://i.imgur.com/3WwfizZ.png) 這時候username的地方記得設定成你在 Github 的 username! 接下來只要把靜態網頁丟到 Github 就大功告成! ## 上傳檔案 :::info 後面的指令也是在欲上傳資料夾中完成,所以前面的指令完成後可以接著打下面的部分! ::: ### 1. 初始化 ``` git init ``` 打完指令後,就會資料夾中一個多出一個檔案叫.git,會儲存git有關的所有資訊!但因為他是隱藏檔,所以打開資料夾是看不到的喔! > 如果想要將.git 刪除 > ``` > rm -r .git > ``` ### 2. 把檔案新增至 staging area - 只新增一個檔案 ``` git add "file name" ``` - 一次新增資料夾中所有檔案 ``` git add . ``` 打完指令就代表將檔案從紅色區域傳送到了藍色區域! ![](https://i.imgur.com/v35Mejt.png) 這時可以查看 git status,看看檔名是不是綠色的,如果有就代表成功上傳! ### 2. 把檔案新增至 local git repository ``` git commit -m "messeges" ``` - 假設我在"messeges"那邊打"first version",在上傳後會出現在檔名旁邊,算是備註的功能 ![](https://i.imgur.com/oGVMFXZ.png) ### 3. push 檔案至遠端 repository :::info 前面步驟都是在 local 端完成的,接下來要 push 至遠端 repo 才算完成上傳的動作! ::: - 設定遠端 repo ``` git remote add <local repo name> <your github repo> ``` 1. <local repo name> 是你的之後用來 push 和 clone 用的網址,通常是打 origin,當然要打別的名稱也是可以! 2. 注意這裡的 <your github repo> ,因為我們前面是選擇 SSH 的方式,所以要填的是 repo 的 SSH 網址喔! 步驟:your repo -> 綠綠的Code -> 選擇 SSH 網址再貼到指令上就行了! ![](https://i.imgur.com/hb1SCx2.png) > 如果遠端網址想要再重新修改 > ``` > git remote set-url <local repo name> <your github repo> > ``` > 查詢對 remote 的命名 > ``` > git remote -v > ``` ### 4. 最後一步! - 一般來說,寫<remote repo name>就行了,不用再另外寫<local repo name> ``` git push <remote address> <local repo name>:<git repo name> ``` > 由於 git 的本地分支預設是 master,如果沒有改變的話,<git repo name> 那邊要打 master 喔! 若最後出現結果顯示下圖的訊息,就代表你已經成功 push 檔案到遠端了! ![](https://i.imgur.com/dsEXwMd.png) 可以到 Github 上確認檔案有沒有上去!

    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