Rather than having to change your credentials every time your GitHub Enterprise passphrase changes, utilize a secure key instead.
- Check for existing keys
ls -l ~/.ssh/*.pub
. If you identify a key you wish to use, skip to step 3. - Create a new key pair
ssh-keygen -t rsa -b 4096 -C [email protected]
- When you're prompted to "Enter a file in which to save the key," press Enter.
- At the prompt to enter a secure passphrase, press enter.
- Adding a passphrase just complicates the configuration. If interested, see working with ssh key passphrases
- In order for git to know about your key, the
ssh-agent
daemon must be configured.- Verify that the
ssh-agent
daemon is running,eval $(ssh-agent -s)
which should show something like> Agent pid <some number>
- Add your private key to the agent,
ssh-add ~/.ssh/<key name>
, default isid_rsa
- Verify that the
- Add public key to GitHub
- Copy public key to clipboard, use either:
- If
clip
installed,clip < ~/.ssh/<key name>.pub
- Otherwise,
cat ~/.ssh/<key name>.pub
to send to console. Copy entire content to clipboard.
- If
- Log in to GitHub, and click on settings from the menu under your profile picture.
- Click SSH and GPG keys then click the New SSH Key button at top right.
- Add a useful title to identify the key.
- Paste the clipboard contents in the key box.
- Click the Add SSH Key button. If prompted enter your GitHub Enterprise password.
- Observe that the key is represented as an md5 signature with your supplied title. If you ever need to confirm signature with local key,
ssh-keygen -E md5 -lf ~/.ssh/<key name>
- Copy public key to clipboard, use either:
✋ When cloning from git, use the ssh option instead of the default https.
- To convert an existing repository to utilize ssh, edit file in
.git/config
replacing any urls with ssh address.
✋ On first use of ssh key you will be prompted to allow the connection to GitHub. Type in "yes" and hit return. This will add GitHub to the known_hosts file (~/.ssh/known_hosts
) which will prevent this prompt from occurring again unless the server IP address changes.