Load SSH keys automatically on macOS
Reference for loading SSH keys if you use macOS.
Read time 1 minuteLast updated 21 days ago
If you use macOS, follow these steps to configure the OpenSSH client so you can use your passphrase-protected SSH key without prompts.
Prerequisites
- macOS 10.13 or later.
Before you begin
Check if you have any existing SSH keys. Refer to the GitHub Docs article, Checking for existing SSH keys.
If you don't have an SSH key:
- Create one by following the GitHub Docs article, Generating a new SSH key.
- Add the new SSH key to your GitHub account, by following the GitHub Docs article, Adding a new SSH key to your GitHub account.
Procedure
-
Check your home folder for ansubdirectory and check if it contains a
.sshfile. Note:configis a hidden subdirectory..ssh -
Create thefile if it doesn't exist.
~/.ssh/config -
Add the following content toto set the key to load in the authentication agent and specify its use by the target server. Make sure you add this entry before any global settings marked as
~/.ssh/config.Host *Host SERVER_NAME UseKeychain yes IdentitiesOnly yes IdentityFile FILE_PATH- is the server that uses the file specified by
SERVER_NAME. A sample value isIdentityFile.github.com - is the path to the SSH file you created. A sample value is
FILE_PATH, where~/.ssh/<FILE>might be<FILE>,id_rsa,id_ecdsa, or a custom name.id_ed25519
Example:Host github.com UseKeychain yes IdentitiesOnly yes IdentityFile ~/.ssh/id_ed25519 -
Open the Terminal application.
-
Load your key file into the, replacing
ssh-agentwith the actual file name of your key, then type your passphrase, if prompted.<FILE>ssh-add ~/.ssh/<FILE>Example:ssh-add ~/.ssh/id_ed25519
Configuration is complete. macOS starts by default, so you can now use the Unity Package Manager to fetch packages from that Git repository over SSH using your passphrase-protected SSH key.
ssh-agent