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: 
```
ssh -l user localhost "sudo whoami"

```

returns:

```
root

```

So long as: 

1. The remote host allows the user connecting to be able to sudo without asking for a further password.
2. ssh-copy-id has been run or correct keys copied across to remote host so that the user can connect again without a password via ssh

All that is different was the word sudo was added before carrying out the command

If there are security issues with keys etc then you could take a look at a language called expect - using an expect script you will be able to ssh / telnet what ever it is to a remote host and send passwords etc accordingly
1. Edit the 
`/etc/ssh/sshd_config` file and change the line that says “PermitRootLogin forced-commands-only” to “PermitRootLogin without-password”.
2. Restart the sshd server with “`service sshd restart`”.
3. Edit the `/root/.ssh/authorized_keys` file. This file should have one line only. It starts by “echo” or “command … sleep 10;” then you can see “ssh-rsa [big long key]”. Remove the text from the beginning of the line until where it says “ssh-rsa”.

SSH your machine using root with your keypair