2018-04-09 ssh 执行别名——通过 ssh 会话执行 bash 别名

  1. 不适用-t则报错如下
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
the input device is not a TTY
  1. 不适用 bash 报错如下:
1589 $ ssh -t dep -ic "alg php"
Warning: Identity file c not accessible: No such file or directory.
bash: alg: command not found
Connection to 47.94.195.121 closed.
  1. ssh -t user@remote /bin/bash -ic 'your-alias-here'

ssh 命令选项: -t强制分配伪终端。可以用来在远程机器上执行任意的 基于屏幕的程序,有时这非常有用。

bash shell 的选项:

-i :运行交互 shell,这样 shell 才能运行 bash 别名。
-c :要执行的命令取之于第一个非选项参数的命令字符串。若在命令字符串后面还有其他参数,这些参数会作为位置参数传递给命令,参数从 $0 开始。

总之,要运行一个名叫 ll 的 bash 别名,可以运行下面命令: ssh -t user@remote /bin/bash -ic 'your-alias-here'

可用的:ssh -t dep bash -ic dphp

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容