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 / 问题 / 805818
Accepted
yael
yael
Asked: 2016-09-29 01:40:35 +0800 CST2016-09-29 01:40:35 +0800 CST 2016-09-29 01:40:35 +0800 CST

是否可以忽略 ssh 上的横幅,但不能忽略登录

  • 772

众所周知,我们可以/etc/motd在文件中或文件中输入banner /etc/issue.net,这样每一个登录Linux机器的用户都会收到banner信息,例如:

Red Hat Enterprise Linux Server release 6.8 (Santiago)
Kernel \r on an \m
##########################################################################
#                               Welcome to OBAMA house !!!
#                         All connections are monitored and recorded
#                Disconnect IMMEDIATELY if you are not an authorized user!
#
##########################################################################

ssh问题是,当我们通过Linux 机器远程登录(而不是本地登录)时,也会显示横幅。

我们可以通过使用以下标志简单地忽略 ssh 中的横幅-q:

ssh -q  192.19.23.45 ls /hillary_emails 

事实上,我们有超过 100 个使用 的 Bash 和 Perl 脚本,所以如果我们向所有机器添加横幅,我们还需要通过添加标志(静默模式)ssh来更改使用该命令的脚本。ssh-q

由于内部原因,我们不想编辑脚本。所以我的问题是,是否可以更改 Linux 客户端配置,使横幅仅在本地登录时显示,而在远程登录时不显示ssh?

linux redhat bash operating-system banner
  • 3 3 个回答
  • 5113 Views

3 个回答

  • Voted
  1. Dom
    2016-09-29T01:59:25+08:002016-09-29T01:59:25+08:00

    我认为 SSHD 选项PrintMotd no可以帮助您。将其添加到 /etc/ssh/sshd_config 中。医生说:

    PrintMotd
                 Specifies whether sshd(8) should print /etc/motd when a user logs in interactively.  (On some systems it is also
                 printed by the shell, /etc/profile, or equivalent.)  The default is “yes”.
    
    • 2
  2. Best Answer
    Itai Ganot
    2016-09-29T02:01:39+08:002016-09-29T02:01:39+08:00

    您可以创建一个组并将相关用户添加到该组:

    groupadd nobanner
    usermod -a -G nobanner username
    

    然后,您可以编辑 /etc/ssh/sshd_config 并添加以下内容:

    Match Group nobanner
        banner "none"
    

    然后,重新启动 sshd 并测试它。

    Match   Introduces a conditional block.  If all of the criteria on the Match 
            line are satisfied, the keywords on the following lines override those 
            set in the global section of the config file, until either another Match 
            line or the end of the file.
    
            The arguments to Match are one or more criteria-pattern pairs.  The 
            available criteria are User, Group, Host, and Address.  The match 
            patterns may consist of single entries or comma-separated lists and may 
            use the wildcard and negation operators described in the PATTERNS 
            section of ssh_config(5).
    
    • 2
  3. janos
    2017-12-18T06:56:34+08:002017-12-18T06:56:34+08:00

    当天的消息不应显示在非交互式会话中。例如,当您运行ssh 192.19.23.45 ls时,非交互式运行命令,并且不应显示当天的消息(“motd”)。

    这同样适用于使用ssh. 脚本将始终以非交互模式执行任务,并且不应显示当天的消息。

    如果您在系统中发现相反的情况,那将是我们可以尝试调试的某种错误配置,但这不是默认行为。

    因此,如果您主要关心的是脚本,那么没有什么可担心的。如果您不希望为使用 远程登录的用户显示当天的消息ssh,那是另一回事,现有的答案可能会有所帮助。(但我认为这个请求有点奇怪:我不明白为什么你不想在他们的交互式远程会话中向用户(非脚本)显示消息。)

    • 0

相关问题

  • 你最喜欢的 Linux 发行版是什么?[关闭]

  • 更改 PHP 的默认配置设置?

  • 保护新的 Ubuntu 服务器 [关闭]

  • 是什么阻止您升级到较新的操作系统版本?[关闭]

  • (软)Ubuntu 7.10 上的 RAID 6,我应该迁移到 8.10 吗?

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