Need to migrate your e-mails to a new server? Free and paid versions of our online tool available.
Hero Image

SSH Key-Based Authentication on Gentoo Linux

SSH Key-Based Authentication on Gentoo Linux

Generate key pair (client)

ssh-keygen -t ed25519 -C "[email protected]"

Copy public key to server

ssh-copy-id -i ~/.ssh/id_ed25519.pub [email protected]

Or manually:

cat ~/.ssh/id_ed25519.pub | ssh user@server \
    "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"

Disable password auth

/etc/ssh/sshd_config:

PasswordAuthentication no

Restart sshd:

systemctl restart sshd 2>/dev/null || rcctl restart sshd 2>/dev/null || service sshd restart

~/.ssh/config shortcut

Host myserver
    HostName server.example.com
    User alice
    Port 2222
    IdentityFile ~/.ssh/id_ed25519
    ServerAliveInterval 60