💡
Knowledge
  • Home
  • Technology
    • Browser
      • Chrome / Brave
        • Known Issues
    • Messaging
      • Discord
        • Known Issues
      • Microsoft Teams
      • Telegram
    • Office Production
      • Sheets
    • Music Production
    • Operational systems
      • Docker + OSX
      • Raspberry Pi OS
      • Linux
        • Terminal
        • Known Issues
        • Desktop Environment
          • Gnome
            • How to
            • Known Issues
            • Theming
          • Kde Plasma
        • How to
          • Audio
          • Proxy
          • SSH
          • ZSH
      • Windows
    • Programming
      • Code Quality
        • Stress Tests
      • Cascading Style Sheets(CSS)
      • Database
        • Postgres
        • SQLServer
      • Design Patterns
      • DevOps
        • Cloud Platforms
        • Continuous Integration
        • Docker
          • How to
          • IPSEC VPN Server
          • Docker Compose
          • Known issues
          • Proxy
        • Swarm
      • Git
        • How to
        • Known Issues
        • Github
        • Gitlab
          • GitlabCI
          • Gitlab Runner
      • IDE / Text Editor
        • Vim
          • Commands
        • PHPStorm
        • VSCode
      • Programming Languages
        • Typescript
        • Java
          • How to
          • Spring Boot
        • Javascript
          • Known issues
          • Backend
            • NestJS
            • NodeJS
          • Frontend
            • JQuery
            • React
            • Vue
          • How to
          • Package Manager
            • Yarn
          • Packages
          • Vanilla
        • PHP
          • About
          • Cache
          • Composer
          • Docker
          • How to
          • Known Issues
          • Laravel
            • Jet Stream
            • Know Issues
            • Sanctum
            • Sail
            • Valet
          • Tools
            • PHPUnit
          • Wordpress
            • Docker
            • WP CLI
            • Known Issues
            • WooComerce
        • Python
        • Shell Script
      • Server
        • Apache2
          • Known Issues
        • Nginx
          • How To
          • Known issues
      • Tools
        • Visual Studio Code
    • Stream
      • Game
      • Twitch
      • Tests
        • Unit Tests
    • Sites
    • Specs
    • Tools
  • Pessoal
    • About me
Powered by GitBook
On this page
  • SSH Key
  • Github Shortcuts
  • Github: Signing commits using GPG (Ubuntu/Mac)
  • Install GPG Tools
  • Generate a new GPG key
  • Answer the questions asked
  • List generated key
  • Make GPG remember your passphrase (tricky)

Was this helpful?

  1. Technology
  2. Programming
  3. Git

Github

PreviousKnown IssuesNextGitlab

Last updated 4 years ago

Was this helpful?

SSH Key

  • Generate key

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  • Add private key to ssh-client

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
  • Install xclip

sudo apt-get install xclip
  • Copy generated file to clipboard (CTRL + C)

xclip -sel clip < ~/.ssh/id_rsa.pub

# Example of generated key
# ssh-rsa AAAB3NzaC1cy2EAAAAADQABAAACAQDF/x8E3SaF8TuBkd/Wl1SAfdcpZ1x5LIQpyU/T6IKYBh3Ez+MgCg8FDZcS41PTgJmdytlYv56DxBkRMjgLb5LhzlAxDBp2zJ3hyHJe/e+DOspoeLSbDbTXk9zRyG6W9K4ucxAyXXly5+dcjI79plMxAuejtw63FNTJ/EBCvF73RLQUsqGesdjE2h1fLM2hYhvXkjlajDS2YwfTaFXfTkt/T1UVjQm45xQW4uY1QDHjyt6GzeSkVcacpgJeUYVdIzSfUPTW+RGPwU/dUaknLSOkBBG+c1FYYh6m4pT6sT1tmmLtOgCbCciGWslRVy2xgXTx+lCpl8r8aqT8YYxxyHRHiV7/WRmoglF9dI4idaUYDb7gs7MJV/ekGGtQKzzCUrkY6YPJguL4S13GN9dvnmIf0YQCAzmv/SbYweqBOs87HJMs6yjwQ5YdTBEBCCHDBBMnXOagOkg6u8sHEytwjrDhqGTNd6x6/BEq9NHyofw6i8tSlfiUL3fsmndWZqUIDhT6rYS6iNTs6a9oSUbbit11xU+B50Pw9Bg5ygfUIdlYrhxVYE6bBX8yGY4H3ivAD2E0+i1vBzOQkrx14W4PW0P0xyvVn5McBaByC2RbcoOBonTPI8FfRvhxAhKvMwoC/Le/n/LVJDy/93sOJEflXgrSCsgiWO45L4+ftlsZ91+dwQ== viniciusfesil@gmail.com
  • Open and Add the ssh key

Github Shortcuts

Shift + /

Github: Signing commits using GPG (Ubuntu/Mac)

  • Do you have a Github account?

    • If not, create one.

  • Install the required tools

Install GPG Tools

# Ubuntu
sudo apt-get install gpa seahorse
# Mac
brew install gpg
gpg --gen-key

Answer the questions asked

Note: When asked to enter your email address, ensure that you enter the verified email address for your GitHub account.

List generated key

gpg --list-secret-keys --keyid-format LONG

# Output
# 
# /home/username/.gnupg/secring.gpg
# -------------------------------
# sec   4096R/<COPY_LONG_KEY> 2016-08-11 [expires: 2018-08-11]
# uid                          User Name <user.name@email.com>
# ssb   4096R/62E5B29EEA7145E 2016-08-11
  • Note down your key COPY_LONG_KEY from above

  • Export this (public) key to a text file

gpg --armor --export <PASTE_LONG_KEY_HERE> > gpg-key.txt
  • The above command will create a new txt file gpg-key.txt

  • Add this key to GitHub

  • Click New GPG Key and paste the content of gpg-key.txt file then save

  • Tell git client to auto sign your future commits

  • Run this command

gpg --list-keys

# Output
# 
# /home/username/.gnupg/pubring.gpg
# -------------------------------
# pub   4096R/<COPY_SHORT_KEY> 2016-08-11 [expires: 2018-08-11]
# uid                  Your Name <user.name@gmail.com>
# sub   4096R/EB61969F 2016-08-11 [expires: 2017-08-11]
  • Copy the short key from above and use this in the command below

git config --global user.signingKey <PASTE_SHORT_KEY_HERE>
git config --global commit.gpgsign true
  • You are done, next time when you commit changes; GPG will ask you the passphrase.

Make GPG remember your passphrase (tricky)

To make it remember your password, you can use gpg-agent

Edit your ~/.gnupg/gpg-agent.conf file and paste these lines

default-cache-ttl 28800
max-cache-ttl 28800

28800 seconds means 8 hours

If gpg-agent is not running you can start it with this command

gpg-agent --daemon

Change your key passphrase

gpg --edit-key <PASTE_YOUR_KEY_ID_HERE>

At the gpg prompt type:

passwd

Type in the current passphrase when prompted Type in the new passphrase twice when prompted Type:

save

Reference Links

Latest

Generate a new GPG

Login to Github and goto profile

Git Client
key
settings
https://help.github.com/categories/gpg/
http://nishanttotla.com/blog/signing-git-commits-gpg/
https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work
https://news.ycombinator.com/item?id=7792026
https://overflow.no/blog/2016/08/11/signed-commits-with-gpg-git-and-github-on-linux/
http://stackoverflow.com/questions/10161198/is-there-a-way-to-autosign-commits-in-git-with-a-gpg-key
http://irtfweb.ifa.hawaii.edu/~lockhart/gpg/gpg-cs.html
https://help.ubuntu.com/community/GnuPrivacyGuardHowto
https://medium.com/@timmywil/sign-your-commits-on-github-with-gpg-566f07762a43#.aovevj80y
https://blog.erincall.com/p/signing-your-git-commits-with-gpg
Github
closed_lock_with_key