I just installed Ubuntu 14.04 and LAMP on that. Then, I wanted to configure my server, so tried out This tutorial.
When I give the command:
ssh root@localhostI get : Permission denied, please try again. I have logged in as root user through the command :
sudo -iI also tried the same, by logging in through:
sudo -sI use the same password as that I used to log in as user, but still am getting the same error message.
Could someone help me out here?
PS: I looked into This question but didn't seem to work for me.
6 Answers
By default, the SSH server denies password-based login for root. In /etc/ssh/sshd_config, if the following line exists, possibly commented out (with a # in front):
PermitRootLogin without-passwordThen change it to the following, uncommenting if needed (remove the # in front):
PermitRootLogin yesAnd restart SSH:
sudo service ssh restartOr, you can use SSH keys. If you don't have one, create one using ssh-keygen (stick to the default for the key, and skip the password if you feel like it). Then do sudo -s (or whatever your preferred method of becoming root is), and add an SSH key to /root/.ssh/authorized_keys:
cat /home/user/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys 6 In some cases, after change,
PermitRootLogin yesmust check this config:
DenyUsers root
AllowUsers saeidand to enable login must change to:
#DenyUsers root
AllowUsers root OtherUser If u have not given password for root and you are trying to fire command on spark or haddop like ./sbin/stop-all.sh or./sbin/start-all.sh . If you don't have a root password, you can setup one using
sudo passwdand fire commands.
I had a similar problem to this. I needed two PCs, one on Ubuntu and another on Arch, to sync files through Unison but ran into the same permission denied error. Just for the sake of those who are having the same problem as I was, here's what I did:
First: Installed the same version of Unison on both PCs. This was a bit challenging as the one available on the software center was behind to what was readily available for Arch. So, I couldn't find a higher version for Ubuntu, so I replaced the one on Arch with a lower one instead. Found one here: . The same version is in the software center for Ubuntu.
Second: Followed the steps from here: (Note: Arch was my server 1 and Ubuntu was my server 2.)
I ran into a problem in step 3 as I tried to ssh-copy. But it was resolved by changing "id_dsa.pub" into "id_rsa.pub" in the "ssh-copy-id -i $HOME/.ssh/id_dsa.pub root@192.168.0.101" line. Probably my fault, as I think I forgot to add "-t dsa". Anyway, try the original command first. IF you get an error, then change to rsa.
After following the steps above, I found I still couldn't get Unison to connect to the other server, neither can I log in (without Unison) through ssh to the other server. Finally,after hours of google searching, I was led to this page, and the answer given my Muru sealed the deal.
After applying it, I could now login via SSH to server 2.
So I ran Unison, and corrected the profile settings, and viola!
TL;DR and like to code in sed to circumvent permission denied in ssh
sed -i s/#\(PermitRootLogin*\).*/\1 yes/ /etc/ssh/sshd_config 1 I faced similar issue with qemu login.
One of the issues could be that authorized_keys on the remote machine does not match with the host machine's key from where you are trying to login.
Copying the id_rsa.pub from host to authorized_keys of the remote PC should help.