Права
chmod 700 ~/.ssh && \
chmod 600 ~/.ssh/* && \
chmod 644 -f ~/.ssh/*.pub ~/.ssh/authorized_keys ~/.ssh/known_hosts ~/.ssh/configили
# Fix directory permissions
chmod 700 ~/.ssh
# Fix all key permissions
chmod 600 ~/.ssh/*
chmod 644 ~/.ssh/*.pub
# Fix special files permissions
chmod 644 ~/.ssh/authorized_keys
chmod 644 ~/.ssh/known_hosts
chmod 644 ~/.ssh/configchown username:usergroup ~/.ssh
chown username:usergroup ~/.ssh/*Генерация новой пары ключей
ssh-keygen -t ed25519 -C <device_name>Добавление ключа на сервер
Заходим на сервер.
Создаем файл ~/.ssh/authorized_keys:
mkdir ~/.sshtouch ~/.ssh/authorized_keyschmod 700 ~/.ssh && \
chmod 600 ~/.ssh/* && \
chmod 644 ~/.ssh/authorized_keysДобавляем публичный ключ:
nano ~/.ssh/authorized_keysОтключение аутентификации по паролю
sudo nano /etc/ssh/sshd_config# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication no
#PermitEmptyPasswords nosudo systemctl restart sshd