How to Use Deploy Keys Github On Computer

Опубликовано: 16 Июнь 2026
на канале: Home Decor Ideas
693
3

Deploy keys on GitHub are SSH keys that are used to grant read-only access to a private repository. They are particularly useful in automation and deployment scenarios where you want a server or service to have access to a repository without using a user account.

Here are the steps to use deploy keys on GitHub:

1. *Generate SSH Key Pair:*

If you don't have an SSH key pair, you'll need to generate one. Open a terminal on your local machine and run:

```bash
ssh-keygen -t rsa -b 4096 -C "[email protected]"
```

Follow the prompts, and you'll generate a new SSH key pair. The public key (`id_rsa.pub`) is what you will add to GitHub.

2. *Add SSH Key to SSH Agent (Optional but recommended):*

If you're using an SSH agent (which is recommended for ease of use), add your private key to it:

```bash
ssh-add ~/.ssh/id_rsa
```

3. *Copy the SSH Public Key:*

Copy the contents of your public key (`id_rsa.pub`). You can do this by running:

```bash
cat ~/.ssh/id_rsa.pub
```

4. *Add SSH Key to GitHub:*

Go to your GitHub repository.
Click on the "Settings" tab.
In the left sidebar, click on "Deploy keys."
Click on "Add deploy key."
Give your key a title (for identification purposes).
Paste your public key into the "Key" field.
Optionally, check the box to "Allow write access" if your deployment process requires write access.

5. *Clone Repository Using SSH:*

When you clone your repository, use the SSH URL. For example:

```bash
git clone [email protected]:username/repository.git
```

Important Considerations:

*Permissions:* Make sure the deploy key has the necessary permissions for the actions it needs to perform. If you need write access (e.g., for pushing changes), you must check the "Allow write access" option when adding the deploy key.

*Scope:* Deploy keys are repository-specific. If you need access to multiple repositories, you might need multiple deploy keys.

*Security:* Treat your private key (`id_rsa`) with the utmost care. Don't expose it, and use a secure method for storing and handling it.

Using deploy keys is a secure way to grant specific permissions to a server or service without compromising your personal SSH key. Always follow security best practices when handling SSH keys.