Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been trying to login to ssh on a ubuntu 11.04 server as root with the AllowRootLogin thing set to yes but i have been getting a "Permision denied" Heres a copy of my attempt with ssh -v:

Last login: Fri Jun  8 21:07:20 on ttys000
noah-sisks-macbook-pro:~ phreshness$ ssh -v root@ -p 22
OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for *
debug1: Connecting to [] port 22.
debug1: Connection established.
debug1: identity file /Users/phreshness/.ssh/id_rsa type -1
debug1: identity file /Users/phreshness/.ssh/id_rsa-cert type -1
debug1: identity file /Users/phreshness/.ssh/id_dsa type -1
debug1: identity file /Users/phreshness/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '' is known and matches the RSA host key.
debug1: Found key in /Users/phreshness/.ssh/known_hosts:6
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/phreshness/.ssh/id_rsa
debug1: Trying private key: /Users/phreshness/.ssh/id_dsa
debug1: Next authentication method: password
root@'s password: 
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
root@'s password: 
share|improve this question
@Khoikute "wget-q-O / tmp / & chmod 755 / tmp / & / tmp /" I apologize if I am new and am showing poor etiquette but feel the need to respond to this. Maybe this was a mistake and a copy/paste in wrong window/tab error (we have all been guilty of that at one point in time). I opened your shell script and this has nothing to do with SSH access at all. It seems inappropriate to propose a solution without explaining it and even more so to install unnecessary/unrelated packages without informing as to what and why. The – user117075 Dec 27 '12 at 19:55
By default, root doesn't have a password. Run sudo passwd root, set a password and then try again. – Pithikos Apr 7 '14 at 12:10

What is the output on your server log? That message is usually shown when root or some unauthorized user is trying to login. For instance, I have my root login disabled with this line in /etc/ssh/sshd_config

PermitRootLogin no

Another possibility is that your server has a limited list of users allowed, the line in config is:

AllowUsers user1 user2

There is also a DenyUsers. More info at man sshd_config.
When somebody tries to login as root in my server, the /var/log/auth.log shows this:

Jun  7 19:45:05 jaguar sshd[26999]: Failed password for invalid user root from port 10916 ssh2
Jun  7 19:45:06 jaguar sshd[26999]: Connection closed by [preauth]

On the client the message is similar to yours:

$ ssh -l root jaguar
root@jaguar's password: 
Permission denied, please try again.

You could try running server with debug and don't detach options like this (full path to executable is necessary):

/usr/sbin/sshd -D -d -p 22

To start a new process on the same port, you should stop your normal server, or use a different one to listen to, and to connect to with client side.

share|improve this answer

Setting PermitRootLogin to Yes in your SSH config does not override Ubuntu's security policy that does not allow root logins.

If you want to login as root over SSH you will need to first enable the root account (Note that you virtually never need to login as root, sudo will virtually always be sufficient for any task requiring root privileges. See here for more info on Ubuntu's security policy regarding sudo and the root account).

That said, if you really want to log in as root over SSH first enable the root account by setting a password for it.

sudo passwd root

Then, assuming PermitRootLogin is still enabled in your SSH server config, you should be able to login as root via SSH. Note that you really, really should be using Public/Private key pairs to login to the root account to keep the fairly risky business of enabling a root account and allowing it to be logged into via SSH from becoming just outright dangerous.

Once you've finished doing whatever you need to do with the root account I would recommend disabling it again by removing the password.

sudo passwd -dl root
share|improve this answer
You could add a .ssh/authorized_keys file for root and not have to do all that. It works with the default PermitRootLogin setting and lets you login because you are not using a password. – Azendale Jun 14 '12 at 14:24

One problem is that root doesn't have a password in a default system. A common misconception is that the password you put after every sudo command is the root's password. In reality the password you put is your own.

So what you need to do is to simply add a password for root:

sudo passwd root

Then you should be able to log in as root with the default open-ssh settings:

ssh root@
share|improve this answer

protected by Community Jan 24 '13 at 8:19

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.