AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 833382
Accepted
Ates Goral
Ates Goral
Asked: 2017-02-19 06:19:25 +0800 CST2017-02-19 06:19:25 +0800 CST 2017-02-19 06:19:25 +0800 CST

使用 augtool 从 /etc/pam.d/sshd 中注释掉或删除 @include

  • 772

如何注释掉或删除 /etc/pam.d/sshd 中的“@include common-auth”行?默认内容为:

...

# 标准的 Un*x 认证。
@include 普通认证

...

镜头文档并不是那么有帮助。我是 Augeas 的新手,还不太清楚路径表达式是如何工作的。

具体来说,我正在尝试使用 augtool 作为 Dockerfile 的一部分来执行此操作。我天真地尝试了以下命令,但没有奏效:

augtool --autosave 'rm /files/etc/pam.d/sshd/@include common-auth'

我求助于这样做sed,以下为我完成了这项工作:

sed -i 's/@include common-auth/#@include common-auth/' /etc/pam.d/sshd

但我仍在尝试找出是否有办法使用 augtool 来完成,因为我正在使用 augtool 在我的 Dockerfile 中进行所有其他配置更改,并且统一性会很好。

pam augeas
  • 1 1 个回答
  • 506 Views

1 个回答

  • Voted
  1. Best Answer
    Dominic Cleal
    2017-02-22T00:24:53+08:002017-02-22T00:24:53+08:00

    尝试确定要编辑/删除哪个节点时,最重要的事情是使用 augtool 的命令查看当前树:print

    $ augtool
    augtool> print /files/etc/pam.d/sshd
    /files/etc/pam.d/sshd
    /files/etc/pam.d/sshd/#comment[1] = "PAM configuration for the Secure Shell service"
    /files/etc/pam.d/sshd/#comment[2] = "Standard Un*x authentication."
    /files/etc/pam.d/sshd/include[1] = "common-auth"
    /files/etc/pam.d/sshd/#comment[3] = "Disallow non-root logins when /etc/nologin exists."
    /files/etc/pam.d/sshd/1
    /files/etc/pam.d/sshd/1/type = "account"
    [..]
    

    这表明该@include common-auth行有 path /files/etc/pam.d/ssh/include[1],所以这将删除它:

    augtool -s 'rm /files/etc/pam.d/sshd/include[1]'
    

    您可以使用路径表达式来匹配值“common-auth”,而不是对索引 (1) 进行硬编码,以确保删除正确的@include条目(如果存在)。

    augtool -s 'rm /files/etc/pam.d/sshd/include[. = "common-auth"]'
    

    .表示节点的值(输出的右侧print)。中的任何内容[]都是路径表达式。Augeas wiki有更多关于路径表达式的信息。

    • 1

相关问题

  • 如何使用 PAM 限制用户的 telnet 登录?

  • 控制台用户被锁定 - pam 问题?

  • 如何在 Subversion 中使用 Linux 用户名和密码?

  • /etc/pam.d/login 与 /etc/pam.d/system-auth

  • Ubuntu linux 密码错误需要更长的时间

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve