This guide explains how to set up private/public key authentication for passwordless SSH, (specifically tailored for Debian systems.)
On your local machine, generate an RSA key pair:
ssh-keygen -t rsa -b 4096
~/.ssh/id_rsa (private key) and ~/.ssh/id_rsa.pub (public key).
Install ssh-copy-id on your local machine if needed (part of openssh-client):
sudo apt update && sudo apt install openssh-client -y
Transfer the public key:
ssh-copy-id user@server
user with a regular user and server with the server’s IP or hostname.Manual Alternative:
ssh user@debian_server
.ssh directory if it doesn’t exist:mkdir -p ~/.ssh && chmod 700 ~/.ssh
~/.ssh/id_rsa.pub from your local machine into ~/.ssh/authorized_keys on the server.chmod 600 ~/.ssh/authorized_keys
Ensure the SSH server is installed and running:
sudo apt install openssh-server -y sudo systemctl enable ssh sudo systemctl start ssh
Verify /etc/ssh/sshd_config allows key-based authentication (default is fine):
PubkeyAuthentication yes.sudo systemctl restart ssh
From your local machine:
ssh user@server
id_rsa) secure and never share it.Caponato's Samba notebook. Start here or else Main menu