Getting Started SSH Keys
SSH Keys
Learn how SSH keys provide secure authentication for remote Git repositories and how to manage them.
SSH keys provide a secure way to authenticate to remote Git repositories without typing your password for every operation.
Instead of sending a password over the network, SSH uses cryptographic keys to prove that your machine is allowed to access the remote service.
SSH in GitComet
GitComet uses your local Git and SSH setup for SSH remotes. Clone, fetch, pull, and push can show authentication, private-key passphrase, and host-verification prompts in the app.
Use an SSH remote URL such as git@github.com:example/project.git when you want key-based authentication. An HTTPS URL uses your Git host's HTTPS authentication and credential helper instead. Changing an SSH key will not change the credentials used by an HTTPS remote.
The commands below manage keys with OpenSSH in your terminal. On Windows, run the shell examples in Git Bash, or use the equivalent paths and commands for your SSH installation.
SSH key basics
SSH authentication uses a keypair:
- a private key stored on your local machine, such as
~/.ssh/id_ed25519 - a public key added to a Git hosting service such as GitHub
The .pub extension indicates that a key file is the public key. For example, ~/.ssh/id_ed25519.pub is the public key that corresponds to ~/.ssh/id_ed25519.
The private key should stay only on devices you trust.
The public key can be shared with the Git service you want to authenticate against.
Managing SSH keys
View your keys
Start by checking whether you already have SSH keys on your machine.
On most systems, SSH keys are stored in the ~/.ssh/ directory.
Inspect an existing public key's type, fingerprint, and comment with:
ssh-keygen -lf ~/.ssh/id_ed25519.pubGenerate a new key
Generate a new key when you do not have one yet or when you want a separate key for a different machine or account.
Ed25519 is a common modern default for Git authentication.
ssh-keygen -t ed25519 -C "your_email@example.com"Import an existing key
If you already have an SSH keypair from another setup, you can import it instead of creating a new one.
Make sure the private key stays secure and that the matching public key is added to the Git service you use.
mkdir -p ~/.ssh
chmod 700 ~/.ssh
cp /path/to/id_ed25519 ~/.ssh/id_ed25519
cp /path/to/id_ed25519.pub ~/.ssh/id_ed25519.pub
chmod 600 ~/.ssh/id_ed25519
chmod 644 ~/.ssh/id_ed25519.pubCopy the public key
When a Git hosting service asks for your SSH key, it expects the contents of the public key file.
cat ~/.ssh/id_ed25519.pubAdd that public key to your account's SSH keys on the Git hosting service. If your key is protected by a passphrase, you can load it into a running SSH agent:
ssh-add ~/.ssh/id_ed25519If GitComet keeps prompting or authentication fails, confirm that it can access the same SSH agent and key configuration as your terminal. On first connection, verify the host fingerprint against your Git hosting service's published fingerprint before accepting it.
Export a key
Export a key only when you need to move it to another trusted system or create a backup.
Treat exported private keys as sensitive secrets.
cp ~/.ssh/id_ed25519 /path/to/backup/id_ed25519
cp ~/.ssh/id_ed25519.pub /path/to/backup/id_ed25519.pubDelete a key
Delete keys you no longer use, especially if a device has been retired or access should be removed.
When deleting a key, also remove the corresponding public key from any Git hosting services where it was registered.
rm ~/.ssh/id_ed25519 ~/.ssh/id_ed25519.pub