sudo ไม่ขอรหัสผ่านแม้ว่าจะมีการรีบู๊ตหลายครั้ง


8

ฉันไม่ได้แก้ไข sudoers ของฉัน แต่ฉันไม่จำเป็นต้องป้อนรหัสผ่านเมื่อทำงานsudoในบรรทัดคำสั่ง ฉันสามารถรันคำสั่ง sudo ใด ๆ โดยไม่ต้องป้อนรหัสผ่านเพียงแค่เปิด terminal แม้หลังจากรีบูตระบบฉันจะหยุดสิ่งนี้ได้อย่างไร

uid=1000(ktcool) gid=1000(ktcool) groups=1000(ktcool),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),1‌​24(sambashare)

5
บัญชีผู้ใช้ของคุณปลอดภัยด้วยรหัสผ่านหรือไม่?
Davidson Chua

5
นอกจากนี้หากคุณป้อนรหัสผ่านในขณะที่ผ่านมาแคชในบางครั้ง
โธมัสวอร์ด

คุณอยู่ในกลุ่มใด การใช้งานและการอ่าน/usr/bin/id man sudoersคุณยังไม่rootได้เป็นคุณ
waltinator

ใช่บัญชีผู้ใช้ของฉันปลอดภัยด้วยรหัสผ่าน แม้หลังจากการรีบูตเครื่องหลายครั้งปัญหาก็ยังคงอยู่ มีใครในพวกคุณที่จะให้ฉันทำงานเพื่อหาว่าฉันแก้ไข sudoers ของฉันโดยไม่ได้ตั้งใจหรือไม่
ktcool

1
มีคำถามที่คล้ายกันใน AskUbuntu การค้นหาใน/etc/sudoersไฟล์และไฟล์ใน/etc/sudoers.dสายที่มีNOPASSWD อาจถูกเพิ่มโดยโปรแกรมระหว่างการติดตั้ง เส้นเหล่านี้ควรเป็นตัวการ

คำตอบ:


7

ใช้visudoเพื่อแก้ไขไฟล์ sudoers ของคุณและค้นหาNOPASSWD:- นั่นเป็นคำสั่งปิดการใช้งานพร้อมท์รหัสผ่านผู้ใช้ (คุณไม่จำเป็นต้องใส่รหัสผ่านของผู้ใช้เป้าหมายเช่นรหัสผ่านรูท) เพียงแค่ลบคำสั่งนั้น (รวมถึงเครื่องหมายจุดคู่ท้าย) คุณจะต้องป้อนรหัสผ่านอีกครั้งเพื่อใช้ sudo (ยกเว้นว่าคุณเพิ่งใช้งานเมื่อเร็ว ๆ นี้จากนั้นจะยังคงแคชอยู่คุณสามารถล้างข้อมูลนี้ได้โดยใช้sudo -k)


0

ใน/etc/sudoersไฟล์กลุ่มผู้ดูแลระบบควรมีลักษณะเช่นนี้%admin ALL=(ALL) ALLและรากบนมืออื่น ๆ ALL=(ALL:ALL) ALLที่เป็น เนื่องจากในเอาต์พุตของidคำสั่งของคุณแสดงว่าคุณอยู่ในหลายกลุ่มเช่น lpadmin ให้ตรวจสอบว่ากลุ่มใดมีบรรทัดเหมือนกับบรรทัดของรูท เปลี่ยนชื่อให้เหมือน admin, save, reboot และแจ้งให้เราทราบว่า thigs กลับมาเป็นปกติหรือไม่


0

ลองsudo --listแสดงการกำหนดค่า sudo ที่ใช้งานอยู่สำหรับบัญชีของคุณ:

skath@beast:~$ sudo --list
Matching Defaults entries for skath on beast:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User skath may run the following commands on beast:
    (ALL : ALL) ALL
skath@beast:~$

ตรวจสอบการประทับเวลาของข้อมูลรับรองแคชซึ่งจะช่วยให้ทราบว่าทำไมคุณไม่ได้รับแจ้ง:

skath@beast:~$ sudo ls -al /var/lib/sudo/$USER/
total 20
drwx------ 2 root skath 4096 Jan 28 14:27 .
drwx------ 3 root root  4096 Jan 28 13:52 ..
-rw------- 1 root skath   40 Feb  5 16:18 1
-rw------- 1 root skath   40 Jan 28 14:51 2
-rw------- 1 root skath   40 Jan 28 13:56 tty1
skath@beast:~$

ใช้sudo --remove-timestampเพื่อพยายามลบข้อมูลรับรองแคชใด ๆ

จากman sudo:

 -K, --remove-timestamp
             Similar to the -k option, except that it removes the
             user's cached credentials entirely and may not be used
             in conjunction with a command or other option.  This
             option does not require a password.  Not all security
             policies support credential caching.

 -k, --reset-timestamp
             When used without a command, invalidates the user's
             cached credentials.  In other words, the next time sudo
             is run a password will be required.  This option does
             not require a password and was added to allow a user to
             revoke sudo permissions from a .logout file.

             When used in conjunction with a command or an option
             that may require a password, this option will cause sudo
             to ignore the user's cached credentials.  As a result,
             sudo will prompt for a password (if one is required by
             the security policy) and will not update the user's
             cached credentials.

             Not all security policies support credential caching.

-1

sudo -i เป็นวิธีที่จะไปหากคุณไม่ต้องการพิมพ์รหัสผ่านทุกขณะแล้วทำการแก้ไขในระบบของคุณ (หรือระบบอื่น ๆ ) และคุณไม่ต้องการแก้ไขไฟล์ระบบใด ๆ มันจะสลับคุณไปroot ใช้sudo รหัสผ่านผู้ใช้ของคุณเมื่อคุณปิดคอนโซลหรือประเภทที่exitคุณกลับไปที่ผู้ใช้ปกติของคุณ หวังว่ามันจะทำงานได้ดี :)


2
ปัญหาคือเขาต้องการที่จะพิมพ์รหัสผ่าน แต่ระบบของเขาไม่ได้รับพร้อมท์แทน แต่จะยอมรับและดำเนินการคำสั่งของเขาราวกับว่าเขาได้พิมพ์ไว้
hmayag
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.