---
tags:
  - servers
---

# Generating SSH key for server access

Using local machine generate new key:

```sh
ssh-keygen -t ed25519 -C "user@clientname" -f ~/.ssh/user_clientname
```

This creates a public/private key pair on the local machine, viz:

```
.ssh/user_clientname
.ssh/user_clientname.pub
```

Get the public key:

```sh
cat .ssh/user_clientname.pub
```

Add to the server's authorized keys:

```sh
echo "PASTE_PUBLIC_KEY_HERE" >> ~/.ssh/authorized_keys
```

Test by using the new public key to connect:

```sh
ssh -i ~/.ssh/user_clientname user@servername
```

Paste the private key into whatever client wants to access the server (e.g.
Forgejo).
