How To Import SSH Key In Ubuntu Server GitHub Installation?

Generate an SSH key on the Ubuntu server:

`ssh-keygen -t ed25519 -C “your_email@example.com”`

Press Enter to accept the default file location

Enter a passphrase if desired

Start the SSH agent:

`eval “$(ssh-agent -s)”`

Add the private key to the SSH agent:

`ssh-add ~/.ssh/id_ed25519`

Copy the public key:

`cat ~/.ssh/id_ed25519.pub`

Add the public key to GitHub:

Go to GitHub

Open `Settings`

Select `SSH and GPG keys`

Click `New SSH key`

Paste the public key

Save the key

Test the SSH connection:

`ssh -T git@github.com`

Configure Git identity if needed:

`git config –global user.name “Your Name”`

`git config –global user.email “your_email@example.com”`

Clone the repository using SSH:

`git clone git@github.com:username/repository.git`

If importing an existing key file, copy it to the server:

`scp ~/.ssh/id_ed25519 user@server:~/.ssh/`

`chmod 600 ~/.ssh/id_ed25519`

`ssh-add ~/.ssh/id_ed25519`

If using a different key name, specify it explicitly:

`ssh-add ~/.ssh/your_key_name`

Suggested for You

Trending Today