欢迎横幅停止 scp

tar*_*nkt 8 login ssh scp profile

我们的团队决定为我们所有的房东添加欢迎横幅。团队成员,而不是添加消息 in/etc/motd添加了带有echoin的消息~/.cshrc

这是scp主机之间的中断。有人可以解释这是如何打破的scp吗?是不是cshrc装的时候scp呢?并且其中的一些回显消息将如何破坏它?

我不知道scp.

我们添加的消息~/.cshrc

echo "##############################################################################"
echo "                              Alert! Aler! Alert! Alert! Alert! Alert!"
echo "This is a restricted box, any actions performed here will be reported to xxx@yyy.com"
echo "##############################################################################"
Run Code Online (Sandbox Code Playgroud)

roa*_*ima 20

运行在ssh传输之上的命令在启动服务器之前不期望有大量输出。这将影响许多实用程序。

解决方案是让您的管理团队仅在stdout连接到终端时才打印消息。

if ( $?prompt ) then
    echo "Secure machine message..."
    echo "More warnings"
    echo "Etc."
endif
Run Code Online (Sandbox Code Playgroud)

更好的是,您根本不会将其放入.cshrc,而是消息内容本身会放入/etc/issue.net登录显示。/etc/ssh/sshd_config不过,这可能需要启用,如下所示:

Banner /etc/issue.net
Run Code Online (Sandbox Code Playgroud)


Mar*_*ryl 7

您无法在非交互式会话中打印任何内容。这会破坏任何使用严格协议(例如 SFTP 或 SCP)的客户端。


使用/etc/motd(仅用于交互式会话)。

或者使用sshd_config指令Banner

或者在打印任何东西之前测试交互式会话(例如,通过测试TERMprompt变量的存在)。


有关背景信息,请参阅我对 Server Fault question SSH MOTD per user 的回答。