I did a recovery of the server and reset the root password to a new one because for some reason, the original was not being recognised. It still is refusing to accept the password in ssh for root. After further research, it appears that it could be a corrupt etc/passwd file.

Parallels state that running this command:

cat /etc/passwd | grep ^root | hexdump -c 

the end of the file should end with, \n but mine ends with \r \n. This file I checked as a user with /bin/bash privs. Now the problem. I cannot check the passwd file at root. Any ideas?

I understand there are 2 etc/passwd locations. 1 for each user allocated on the system and the 2nd is in the etc root area. Thanks

4 Answers 4


You've edited the file /etc/passwd with a Windows editor, or with an editor configured to produce Windows files. Don't do that. Windows uses the two-character sequence CR-LF to represent a line break, whereas Linux and other unix systems use just LF and see that CR as an ordinary character that happens to be last on its line. Generally speaking, use a Linux editor to edit files on Linux, or if you use a Windows editor, make sure to save the file in Linux newline format.

Your problem is now not that the password is invalid. You are getting successfully authenticated. At the end of the login process, the last thing that login or su or sshd does is to run your shell as recorded in /etc/passwd. It happens that the shell is the last column of /etc/passwd, so now root's shell has been set to /bin/bash␍ where is a CR character.

You need to arrange to either create this file or edit /etc/passwd. You will need root access for either of those. Since you've effectively disabled the root account, you'll need physical access.

  • Thanks for your comments Giles. This file has now been edited and happened after a plesk update. It was working fine before the update. Commented Jul 24, 2014 at 11:22

Does it accept the password from the console? you might have upgraded your system and your sshd_config might have been replaced. By default root access through ssh is disabled. By the way, the password is not stored in /etc/passwd, it is stored in /etc/shadow. The only thing affected would be your login shell which is what is the last field of /etc/passwd why don't you edit that file and remove the \r? Is your user in the sudoers list? if so do a sudo bash and edit the file.

  • Thank you for your comment. I have tried to edit the file in vi and nano, but when I save the file, it says it is locked for writing. It does not accept the password from the console. I am not familiar with sudo as I am fairly new to centos and still finding my way. Is there a tut Iyou would suggest for a new user to read up on> Many thanks Commented Jul 23, 2014 at 9:19
  • When I try sudo bash I get error of: user is not in the sudoers file. Commented Jul 23, 2014 at 9:24
  • What about the access through the console? do you have access to the physical machine? if you do, you can start your machine with a live CD or the like, mount your hard drive and modify the passwd to remove the \r. The problem may be that the system can't start the shell because of that character.
    – YoMismo
    Commented Jul 23, 2014 at 10:18
  • I have done that. Ran recovery mounted drive and created new root password. When the server rebooted, I still could not login to shh as root. I am using ssh client to connect and it does not accpet pass there either. I can login as a user but cannot change to root. Commented Jul 23, 2014 at 10:23
  • I didn't say anything about creating a new root password, just edit the oldone. If the problem is the password, you will need to mount your HD, chroot to your HD, run passwd command and change your password. Then try to reboot and access WITHOUT SSH, right through the console as root.
    – YoMismo
    Commented Jul 23, 2014 at 10:48

Try the following when logged in:

su root

Then you login as root. When this works, you can edit the passwd file.

  • Problem is it doesn't accept root password. Get error of: No such file or directory, Which according to plesk indicates malformed passwd file. Thanks Commented Jul 23, 2014 at 10:20
  • Do you have physical access to the server, and can you take out the harddisk and attach it to another machine? Then you can change that corrupt file. Make sure to rename it first so you can always move it back. If you can start a centos live system from cd or usb that might work as well.
    – SPRBRN
    Commented Jul 23, 2014 at 10:23
  • I do not have physical access to machine and I have run the recovery program. No errors or problems. But, still no cigar re root access. Commented Jul 23, 2014 at 10:52

FYI -- if anyone runs across this in a search.

You can't su or sudo su - with a corrupt passwd file. It'll say No such shell bash^M.

But you can run sudo su -s /bin/bash to specify an alternate shell to run. Or su -s /bin/bash if you have root's password.

You must log in to answer this question.

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