linux - ssh连接时自动启动程序

标签 linux ssh command-line

当有人通过 ssh 连接时,如何自动启动程序。

对于 ubuntu,当有人使用 ssh 连接时,它会自动显示是否有可用的更新。我想要一个应用程序在有人登录时自动运行以向他们显示一些信息。

我在 Google 上搜索过,试图找到类似的东西,但我唯一能找到的是如何让 ssh 服务在开机时自动启动。

最佳答案

您可以将脚本放在 ~/.ssh/rc 中。来自sshdman 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/

相关文章:

c - linux下如何获取随机文件?包括子目录

c++ - 当我在 Linux 上使用 STL 编译 C++ 程序时,STL 库是如何链接的?

windows - 没有明显原因的非常基本的脚本中的 "The input line is too long"错误

shell - 是否可以在远程 ssh 命令中使用变量?

regex - 如何检查 bash 中字符串的最后一个字符?

mysql - 通过命令行在 MySQL (Windows 8.1) 上安装 'Employees Sample Database'

c - 如何等待任何/所有 pthread 完成?

linux - Git 大文件存储/如何在 AWS EC2 Linux 上安装 git lfs 2/"No package git-lfs available."

Laravel Homestead vagrant up 超时

ssh - Vagrant 1.9.6 在命令 "vagrant ssh"上挂起