ssh执行远程服务器的命令别名
在 Unix 系统上无法直接通过 ssh 客户端执行 bash 别名
别名命令找不到
ssh user@remote jimodododo
需要这样写
ssh -t user@remote /bin/bash -ic 'jimodododo'
ssh 命令选项:
-t:强制分配伪终端。
可以用来在远程机器上执行任意的 基于屏幕的程序,有时这非常有用。
当使用 -t 时你可能会收到一个类似 “bash: cannot set terminal process group (-1): Inappropriate ioctl for device. bash: no job control in this shell .” 的错误。
bash shell 的选项:
-i:运行交互 shell,这样 shell 才能运行 bash 别名。
-c:要执行的命令取之于第一个非选项参数的命令字符串。
若在命令字符串后面还有其他参数,这些参数会作为位置参数传递给命令,参数从 $0 开始。