Create & Connect with SSH⚓︎
This guide helps you create an SSH key pair and connect to a remote server using SSH.
Check for Existing SSH Keys⚓︎
First, check if you already have SSH keys on your local machine:
If you see files like id_ed25519/id_ed25519.pub or id_rsa/id_rsa.pub, you already have an SSH key pair. If not, proceed to the next step.
Generate a New SSH Key Pair⚓︎
Generate a new SSH key pair using the following command. We recommend using the Ed25519 algorithm for better security:
(You will be prompted to enter a passphrase. This is optional but recommended for added security. Press Enter to skip.)
This will create two files: ~/.ssh/id_ed25519 (private key) and ~/.ssh/id_ed25519.pub (public key).
Add SSH Key to SSH-Agent (Optional)⚓︎
The SSH agent manages your SSH keys. It helps you avoid entering your passphrase every time you use the key. If you don't have passphrase, you can skip this step.
Copy the Public Key to the Remote Server⚓︎
Manually copy the public key:
cat ~/.ssh/id_ed25519.pub
>>> ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... your_email@example.com
Paste the copyboard content into the remote server.
- Log in to your GitHub account.
- Go to Settings > SSH and GPG keys.
- Click New SSH key.
- Paste your public key into the "Key" field and give it a title.
- Click Add SSH key.
- Log in to your Bitbucket account.
- Go to Personal settings > SSH keys.
- Click Add key.
- Paste your public key into the "Key" field and give it a label.
- Click Add SSH key.
Test SSH Connection⚓︎
SSH Config File (Optional)⚓︎
You can create an SSH config file to simplify SSH connections to multiple servers. Create or edit the ~/.ssh/config file:
Add the following configuration for your server:
Host github.com # (1)
HostName github.com # (2)
User git # (3)
IdentityFile ~/.ssh/id_ed25519
Host your-server-alias
HostName your.server.com
User your-username
IdentityFile ~/.ssh/id_ed25519
Host: An alias for the server. You can use this alias to connect instead of the full hostname.HostName: The actual hostname or IP address of the server.User: Your username on the remote server.