How to prepare deploy key for GitHub on Linux

1. Generate key

$ ssh-keygen -t ed25519 -C ""

# Generating public/private ed25519 key pair.
# Enter file in which to save the key (/home/user/.ssh/id_ed25519): [Press enter]
# Created directory '/home/user/.ssh'.
# Enter passphrase (empty for no passphrase): [Press enter]
# Enter same passphrase again: [Press enter]
# Your identification has been saved in /home/user/.ssh/id_ed25519.
# Your public key has been saved in /home/user/.ssh/
# The key fingerprint is:
# SHA256:9FypGi35JlcZ3O459VoyM4qTTCQTbTlIkohd3DNrMkU

2. Copy key

# grab generated string
$ cat /home/user/.ssh/

# ssh-ed25519 AAuZC3NzaC1lZDI1NTE5TzTAIOiGJohB9Doz4H0w6+GnrBdbOTwjRhN3CqYYurE5ZYPO

3. Add that key to repo

Go to ➤ Choose related repo ➤ Settings ➤ Deploy keys ➤ Add deploy key ➤ Save just generated key.

4. Prepare configuration file

Add next lines in /etc/ssh/ssh_config file:

Host my_custom_git_host
    User git

5. Test local key

ssh -T my_custom_git_host

If some error occurs, check by debugging it in verbose mode:

ssh -vT my_custom_git_host

If everything is ok, you should see smth. like this:

# Hi Organization/project! You've successfully authenticated, but GitHub does not provide shell access.

6. Finally test Push/Pull request

$ git remote add origin git@my_custom_git_host:organization/project.git
$ git push origin main


Leave a Reply