Question: In my project, I have to install some package remotely. If I have to login in debian, I say: 

```
$ ssh root@remotehostname
root@remotehostname's password: 

```

it logs in successfully. 

I have login in **ubuntu** in directly using

```
 $ root@remotehostname
 root@remotehostname's password:

```

it is throw error message in

```
Permission denied, please try again.

```

How to solve this problem?

Answer: 
**Do not enable the root account. Do not set a password for the root account.**

A better way is to allow root login using public key authentication, not with password. [The reasoning is explained in the Debian mailing list archives.](http://lists.debian.org/debian-security/2002/06/msg00418.html)

1. Open `/etc/ssh/sshd_config` and check if `PermitRootLogin` is set to `yes`. If not, then set it to yes and restart `ssh` with `sudo service ssh restart`
2. Create the `.ssh` directory in root's home if it doesn't exist and make sure it has strict permissions:

```
sudo -i mkdir -p .ssh
sudo -i chmod 700 .ssh

```
3. Create a public/private key pair in the system you want to login from.
4. Copy your public key to your regular user account.
5. Append your public key to `.ssh/authorized_keys` of root, and make sure the file has strict permissions:

```
cat id_rsa.pub | sudo -i tee -a .ssh/authorized_keys
sudo -i chmod 600 .ssh/authorized_keys

```

With this setup you should be able to login as root using your private key.

If you have previously enabled the `root` account, make sure to disable it now:

```
sudo passwd -l root

```
By default, the Root account password is locked in Debian based systems like Ubuntu:

Switch to `root` account user:

```
sudo -i;

```

Now set the password for root account:

```
sudo passwd;

```

Simply adding a password for root is not enough. 

Incoming ssh connections need to be enabled as below:

Edit `/etc/ssh/sshd_config`, and find out the following line:

```
PermitRootLogin without-password

```

Just replace the word `without-password` with `yes`, as in the following line:

```
PermitRootLogin yes

```

Then restart SSH:

```
sudo service ssh restart;

```

Finally Restart the system:

```
sudo reboot;

```

Done !!!