sudo密码超时设置,避免短时间内多次输入

Kevin 教程 6,156 次浏览 77条评论

sudo是Linux下进行提权操作的授权程序,在经由管理员设置账户允许使用sudo后。那些需要root权限的操作,只需在命令前添加sudo,完成账户密码验证,相关操作即会以root权限运行。在这过程中,若要以不连续方式运行多条命令(间隔超过5分钟),sudo程序会要求重新输入密码验证。

这是sudo的一种安全机制,当用户成功使用sudo会生成一条记录。其中包含时间戳、用户ID、终端会话ID,之后5分钟内再次使用将无需输入密码。这个时间可以自定义设置,具体方法如下。

设置方法

1. 运行下面命令修改/etc/sudoers配置文件。需确保操作账户具有修改权限,wheel组账户可以满足要求,没有请切换root身份操作。

sudo visudo

注意不要用其它编辑器修改文件,因为可能存在语法问题,visudo会在保存时检查语法是否正确。

2. 打开文件后操作方法和vi编辑器一样(Ubuntu则是nano),在文件最后添加一行,内容如下。

Defaults:username timestamp_timeout=20

蓝色字符是账户名,红色是sudo密码缓存时长,单位分钟。若设置0,则每次操作都要密码确认。

如果文件内存在多条设置规则,后面的规则会覆盖先前的规则。

3 平时用完sudo后可以通过sudo -k命令清除密码缓存,使其重新开始计时。另外在不进行实际操作情况下,可以用sudo -v命令开始缓存。

结束语

虽然也可以直接关闭密码验证,一了百了解决问题。但这样会减低安全性,不建议也没有必要。如果需要长时间无密码操作,可以用sudo susudo -s命令临时切换root操作,退出用exit命令。

对于某些常用的操作,例如systemctl之类的,还可以创建NOPASSWD规则设置部分操作不要密码验证。具体可见man文档介绍。

评论列表

  1. #1

    Hi, very nice website, cheers!
    ——————————————————
    Need cheap and reliable hosting? Our shared plans start at $10 for an year and VPS plans for $6/Mo.
    ——————————————————
    Check here: https://www.reliable-webhosting.com/

  2. #2

    average cost of cialis prescription https://buszcentrum.com/

  3. #3

    acyclovir 250 mg tablet https://www.herpessymptomsinmen.org/productacyclovir/

  4. #4

    lumigan coupons from allergan https://carepro1st.com/

  5. #5

    clomid ingredients vs clomiphene ingredients https://salemeds24.wixsite.com/clomid

  6. #6

    generic tadalafil united states http://www.lm360.us/

  7. #7

    silagra long term safety https://silagra.buszcentrum.com/

  8. #8

    blue pill suhagra from mexico https://suhagra.buszcentrum.com/

  9. #9

    is ivermectin poison https://ivermectin.webbfenix.com/

  10. #10

    plaquenil hydroxychloroquine for lupus https://hhydroxychloroquine.com/

  11. #11

    usa vidalista https://vidalista.mlsmalta.com/

  12. #12

    hydroxychloroquine for osteoarthritis https://hydroxychloroquine.webbfenix.com/

  13. #13

    order hydroxychloroquine https://hydroxychloroquine.mlsmalta.com/

  14. #14

    ivermectin pills cvs https://ivermectin.mlsmalta.com/

  15. #15

    overnight delivery viagra http://droga5.net/

  16. #16

    generic cialis fda approved https://wisig.org/

  17. #17

    taking cialis and viagra https://tadalafili.com/

  18. #18

    viagra or vidalista jovidalistarl https://vidalista40mg.mlsmalta.com/

  19. #19

    dexamethasone 0.75 mg

  20. #20

    salbutamol inhaler dosage https://amstyles.com/

  21. #21

    mobic tabs

  22. #22

    161510 aspirin

  23. #23

    nationwide car insurance quote

  24. #24

    loan b

  25. #25

    car insurance compare

  26. #26

    free adult cams

  27. #27

    prescription free canadian pharmacy

  28. #28

    how much is cialis 20mg

  29. #29

    how is hydroxychloroquine made https://hydroxychloroquinee.com/

  30. #30

    fast loans

  31. #31

    homeowners insurance quotes florida

  32. #32

    dapoxetine users testimonials https://ddapoxetine.com/

  33. #33

    property insurance

  34. #34

    cialis online pharmacy paypal

  35. #35

    margin loan

  36. #36

    average home insurance cost by zip code

  37. #37

    lasix rx

  38. #38

    homeowner insurance

  39. #39

    hydroxychloroquine interaction https://sale.azhydroxychloroquine.com/

  40. #40

    professional generic cenforce 100mg http://cavalrymenforromney.com/

  41. #41

    medication for marijuana addiction https://edmeds.buszcentrum.com/

  42. #42

    medication for marijuana addiction https://buymeds.mlsmalta.com/

  43. #43

    does female dapoxetine work https://dapoxetine.confrancisyalgomas.com/

  44. #44

    cialis samples for physicians office http://cleckleyfloors.com/

  45. #45

    how to take liquid cialis https://cialzi.com/

  46. #46

    cialis cost generic https://tadalafil.cleckleyfloors.com/

  47. #47

    best generic cialis review http://ciaalis2u.com/

  48. #48

    vidalista prescription http://vidallista.com/

  49. #49

    prescription refill no insurance https://medpills.bee-rich.com/

  50. #50

    aurogra vs tadalafil pah https://aurogra.buszcentrum.com/

  51. #51

    ivermectin without prescription http://ivermmectin.com/

  52. #52

    tadalafil and cialis sales https://cialis.buszcentrum.com/

  53. #53

    tadalafil and cialis sales https://cialis.lm360.us/

  54. #54

    directions for taking viagra 100mg http://viaagra1.com/

  55. #55

    generic tadalafil without doctor visit https://atadalafil.online/

  56. #56

    buy viagra 100mg without script http://viiagra.co/

  57. #57

    Hello i am kavin, its my first time to commenting anywhere, when i read this
    article i thought i could also create comment due to this brilliant paragraph. http://cleckleyfloors.com/viagra

  58. #58

    Hi there everybody, here every one is sharing these familiarity, thus it’s
    nice to read this webpage, and I used to go to see
    this weblog everyday. https://cialis.advantagetriseal.com/tadalafil

  59. #59

    It’s very trouble-free to find out any matter
    on net as compared to textbooks, as I found this paragraph at this
    web site. https://hydroxychloroquineb.bee-rich.com/

  60. #60

    Article writing is also a fun, if you be familiar with then you can write or else it is complex to write. https://hydroxychloroquines.studiowestinc.com/

  61. #61

    Hello, Neat post. There is an issue with your site in internet explorer, may check thisK IE nonetheless is the marketplace leader and a large section of people will leave out your fantastic writing due to this problem.

    http://www.vreyrolinomit.com/

  62. #62

    Hello, i read your blog occasionally and i own a similar one and i was just wondering
    if you get a lot of spam feedback? If so how do you prevent it, any plugin or anything you can advise?
    I get so much lately it’s driving me crazy so any support is very much appreciated. http://www.deinformedvoters.org/cialis-usa

  63. #63

    I could not resist commenting. Very well written! http://www.deinformedvoters.org/dapoxetine-60mg

  64. #64

    how long is ivermectin effective https://ivermectin1st.com/

  65. #65

    buy cialis online us pharmacy http://edonline.online/

  66. #66

    buy cialis online us pharmacy http://edbuy.online/

  67. #67

    I conceive this site has some real superb info for everyone : D.

    http://www.zortilonrel.com/

  68. #68

    buy hydroxychloroquine online https://hydroxychloroquinex.com/

  69. #69

    amei este site. Para saber mais detalhes acesse o site e descubra mais. Todas as informações contidas são conteúdos relevantes e exclusivas. Tudo que você precisa saber está ta lá.

    https://corporality.global/

  70. #70

    Great ?V I should certainly pronounce, impressed with your site. I had no trouble navigating through all the tabs as well as related info ended up being truly simple to do to access. I recently found what I hoped for before you know it in the least. Quite unusual. Is likely to appreciate it for those who add forums or anything, web site theme . a tones way for your client to communicate. Nice task..

    http://www.vreyrolinomit.com/

  71. #71

    vidalista tablets price in india http://viidalista.co/

  72. #72

    Appreciating the persistence you put into your site and detailed information you provide.
    It’s great to come across a blog every once in a while that isn’t the same outdated
    rehashed information. Great read! I’ve bookmarked your site and I’m adding your RSS feeds to my Google account. https://hydroxychloroquinec.cleckleyfloors.com/

  73. #73

    Adverse effects of tadalafil boxtadafil.com tadalafil farmacodinamica

  74. #74

    Hey there, I think your blog might be having browser compatibility
    issues. When I look at your blog site in Opera, it looks fine but when opening in Internet Explorer, it has some overlapping.

    I just wanted to give you a quick heads up!
    Other then that, great blog! http://www.deinformedvoters.org/aurogra-online

  75. #75

    Very nice style and design and great content, hardly anything else we need : D.

    https://www.youtube.com/watch?v=vIeo40k99nY

  76. #76

    Buy 10 mg cialis asciled.com cialis and
    dapoxetine

  77. #77

    Cialis without precription http://cileve.com/ cialis shop in australia

发表评论

电邮地址用于 Gravatar 头像显示,不会被公开可见。