---
description: meta description
tags: ubuntu, ssh
---
Allow root ssh login with public key authentication
=
1. As root, edit the sshd daemon configuration file (/etc/ssh/sshd_config).
2. Modify the PermitRootLogin and the PubkeyAuthentication parameters to have the following values.
```bash=
PermitRootLogin without-password
PubkeyAuthentication yes
```
3. gen host key
```bash=
$ ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
$ ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
$ chmod 600 /etc/ssh/ssh_host_dsa_key
$ chmod 600 /etc/ssh/ssh_host_rsa_key
```
4. Restart the sshd daemon.
```bash=
$ systemctl restart sshd.service
```
5. Copy public key into target
```bash=
mkdir -p ~/.ssh/
cat << EOF > ~/.ssh/authorized_keys
ssh-rsa ...
EOF
```