【问题标题】:Disable ssh message禁用 ssh 消息
【发布时间】:2017-04-19 05:19:23
【问题描述】:

当我通过 SSH 连接到基于 Ubuntu 的 Docker 容器时,每次都会显示以下消息。

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

我想禁用显示它,但找不到方法。
有什么办法吗?如果可以的话,请告诉我怎么做。

【问题讨论】:

标签: ubuntu ssh


【解决方案1】:

从技术上讲,您可以使用以下命令使它们消失。 您只需将该消息转发到一个文件,然后在您注销时将其删除。

ssh -t user@192.168.XXX.XXX '> dis.txt; bash -l'

注意 -t 选项是执行 bash 命令所必需的。

但是这会要求输入密码。上面的一个更简化的版本和纯粹的东西是使用 sshpass。

sshpass -p 'password' ssh -t user@192.168.XXX.XXX '> dis.txt; bash -l'

上面的很简单,只要连接就可以了。

记得替换“密码”和“用户”和主机地址。

退出前输入以下命令

rm dis.txt 

最后一步其实不需要,由你决定。

请参考:How can I disable greeting message when ssh in to a server?

【讨论】:

    【解决方案2】:

    我现在的回答:

     sed -i 's/PrintLastLog yes/PrintLastLog no/' /etc/ssh/sshd_config
     touch /home/$USER/.hushlogin
    

    我在主目录中需要 PrintLastLog no 和 .hashlogin。

    【讨论】:

      猜你喜欢
      • 2015-09-20
      • 1970-01-01
      • 1970-01-01
      • 2013-05-30
      • 2018-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多