Configure key authentication to login Ubuntu (i)

Source: Internet
Author: User

Behind every seemingly effortless result there is untold bitterness. Another small thing, the result of a day of tossing.

After the configuration of SSH and samba, the Python programming practice began. Because really do not use VIM, so the final programming environment in Windows with notepad++ write code, through the Samba server update directly sync to Ubuntu, the day with a good, the Python file operation this part is a small test sledgehammer a bit.

After a sleep, the tragedy began: SSH started to connect! SSH localhost does not work.

Error 1:connection Reset by peer

Error 2:connection refused

Frankly speaking, both of these errors have been met before, is a more common mistake, but Google seems to have not seen a particularly good solution, but it can be concluded that the Sshd_config configuration file has a problem.

Use grep sshd/var/log/auth.log to view the error logs associated with the next SSH service.

tragedy 2: In order to view the configuration file conveniently, a chmod 777-r/etc/executed (initially only in Python workdirectory set 777)

The result is that the sudo command will never be executed again.

Error 3:

sudo:/etc/sudoers is world writable
Sudo:no valid sudoers sources found, quitting
Sudo:unable to initialize policy plugin

/etc/sudoers by default, only root has Read access (440),

[Email protected]:~$ ll/etc/sudoers
-r--r-----1 root root 745 February 2014/etc/sudoer

It appears that the system detected a change in the read/write properties of the/etc/sudoers and then gave a reminder. So now all of Sudo's commands cannot be executed. To say that in the 12.04 version of the time seems to have done so, but did not have this problem, let's think that the 14.04 version of the security and improved.

Keywords dropped into Google, almost did not spit blood. This is almost a fatal error: either reload the system, either with USB portable or boot into recovery/single mode, into the root shell and set the file permissions back. Both of these methods are not good, finally found a bypass method:

Http://askubuntu.com/questions/304212/how-to-solve-sudo-etc-sudoers-d-is-world-writable

#pkexec chmod 0440/etc/sudoers

This command can be executed under the ordinary user, the execution will pop up a graphical dialog box, you need to enter the root password, and then cut into root.

Was cut back, pinched a sweat. Of course, the next brain is hot, did not understand the correct permissions/etc/sudoer, the hands of the cheap #chmod 600/etc-r is another tragedy:

Error 4:

sudo:/etc/sudoers is owned by UID-should be 0

sudo: Unable to stat/etc/sudoers.d/readme:no such file or directory

This time #pkexec chmod 0440/etc/sudoers also can not execute, and Google down most also point to the first mentioned two methods.

(1) USB access

Because it is Hyper-V virtual machine mode, modify boot sequence, from the CD-ROM drive loading ISO boot, enter after the selection "Try Ubuntu", using the default Ubuntu users can directly into root, check that my previous home/home directory does not exist, the feeling that this method is not possible, Switch directly to the next method.

(2-1) Single mode

This is often the way to forget the root password.

A) When the Grub screen appears, use the up and down keys to select the one you normally start Linux on, and then press the E key

b). Use the up and down keys again to select the one you normally start Linux (similar to kernel/boot/vmlinuz-2.4.18-14 ro root=label=/), then press the E key

c). Modify the command line you see now, add single, and the results are as follows:

Kernel/boot/vmlinuz-2.4.18-14 single RO root=label=/

d). Enter return, then press B to start and go directly to the Linux command line

e). Enter passwd and enter the new password two times;

f). #reboot重启

This is the ideal situation, previously in CentOS and Blacktrack also practiced, the problem is not big. As a result this time in Ubuntu 14.04, after entering the edit mode, actually appeared if else mode, iers grub also become complicated. I do not know where to add a single, think it is really anxious to go back to the 12.04 version of the system is familiar with the good, give up.

(2-2) Recovery mode

This is really a slot point, the boot has been stuck in the "booting system without full network configuration".

I did not remember that the Linux system must also check the network (not a must), this is actually planted on this, and Ctrl+alt+f1, entered the character interface, but has not appeared root shell. also give up.

So finally, after a morning's toss, the result is: Reload the system.

So far, it also confirms the previous article mentioned: Spend n more time to solve a problem, it is better to re-install the system quickly. It seems that the process of reading someone's code is not as good as what the developer said, but rather than re-writing the code.

The Hanging machine re-installed the system, the afternoon continues.

Configure key authentication to login Ubuntu (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.