我想知道是否有办法指定登录时要运行的脚本(在远程机器上)。我正在使用密钥对身份验证(无需密码)登录 Debian 机器。需要运行的脚本会不一样,所以不想放到~/.bashrc里面,想登录的时候在命令行指定一下,比如:
ssh username@ip script_on_remote.sh
你的例子几乎就是你怎么做的。如果在 $PATH 上无法访问脚本,您可以使用它的完整路径来指定脚本。
# if scripts on the $PATH
ssh username@ip script_on_remote.sh
# if it's not on the path
ssh username@ip /path/to/my/script_on_remote.sh
# if it's including spaces
ssh username@ip "/path to my/script_on_remote.sh"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
139 次 |
| 最近记录: |