Create and add SSH keys
An SSH key replaces your password with a pair of files. The private key stays on your computer. The public key goes on the server. Keys are safer than passwords and they're needed for tools such as Git deploy.
Create a key
On your computer:
ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/id_ed25519_barbrick
When asked, set a passphrase. Two files appear:
| File | What it is |
|---|---|
id_ed25519_barbrick |
Private key. Never share or upload it |
id_ed25519_barbrick.pub |
Public key. This is what you add to the server |
Show the public key:
cat ~/.ssh/id_ed25519_barbrick.pub
Add it to your account
- Open Account → Hosting → your site → Developer.
- Under SSH access, click Add a public key.
- Give it a name. Paste the public key into Public key. Click Add key.
The key works for SSH right away.
Connect
ssh -i ~/.ssh/id_ed25519_barbrick [email protected] -p 1988
Save it in ~/.ssh/config
Create or edit ~/.ssh/config on your computer:
Host barbrick
HostName example.ca
User yourusername
Port 1988
IdentityFile ~/.ssh/id_ed25519_barbrick
IdentitiesOnly yes
ServerAliveInterval 60
AddKeysToAgent yes
UseKeychain yes
SSH on Barbrick uses port 1988, not the usual 22. UseKeychain is for macOS only. Remove it on Linux and Windows.
Now connect with one word:
ssh barbrick
sftp barbrick
scp site.zip barbrick:~/
Use the key with Git
Add the same key to GitHub or GitLab, or generate a deploy key on the server. See Deploy with Git.
Housekeeping
- Use one key per computer.
- Remove keys for lost laptops: under SSH access in Developer, click Remove next to the key.
- Back up your private key in a password manager.
- Set permissions if SSH complains:
chmod 600 ~/.ssh/id_ed25519_barbrick.
If something goes wrong
- "Permission denied (publickey)": the key isn't authorized, or you're using a different key. Run
ssh -v barbrickto see which keys are tried. - "Unprotected private key file": run the
chmod 600command. - Asked for passphrase each time:
ssh-add --apple-use-keychain ~/.ssh/id_ed25519_barbrick(macOS) orssh-add(Linux).
Still stuck? Ask us and we'll walk you through it.