当有人通过 ssh 连接时,如何自动启动程序。
对于 ubuntu,当有人使用 ssh 连接时,它会自动显示是否有可用的更新。我想要一个应用程序在有人登录时自动运行以向他们显示一些信息。
我在 Google 上搜索过,试图找到类似的东西,但我唯一能找到的是如何让 ssh 服务在开机时自动启动。
最佳答案
您可以将脚本放在 ~/.ssh/rc
中。来自sshd
man page :
~/.ssh/rc
Contains initialization routines to be run before the user's home directory becomes accessible. This file should be writable only by the user, and need not be readable by anyone else.
您也可以使用 /etc/ssh/sshrc
文件。
/etc/ssh/sshrc
Similar to ~/.ssh/rc, it can be used to specify machine-specific login-time initializations globally. This file should be writable only by root, and should be world-readable.
有关详细信息,请阅读 SSHRC section of the sshd man page .
关于linux - ssh连接时自动启动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37353669/