ssh 执行远程命令卡住问题解决
生活随笔
收集整理的這篇文章主要介紹了
ssh 执行远程命令卡住问题解决
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
問題現象
我這邊執行的pc-ctl命令,這個是tidb的pd命令行工具
命令本地會自行的結果如下:
但是通過ssh遠程執行pd-ctl會卡住
[root@centos7 ~]# ssh root@127.0.0.1 "/root/pd-ctl -u 10.226.157.132:2900 region" The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established. ECDSA key fingerprint is SHA256:yWPZSs92gAknt9ycN17tNs9NBZGIF/RA0PSn9evBx7o. ECDSA key fingerprint is MD5:00:74:b3:d5:bc:2f:14:dc:8a:e6:88:03:12:9f:7f:67. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts. root@127.0.0.1's password: #輸入密碼后卡住了^CKilled by signal 2. #通過ctrl + c停止 [root@centos7 ~]#解決方法
是用ssh -t 就可以了
[root@centos7 ~]# ssh -t root@127.0.0.1 "/root/pd-ctl -u 10.226.157.132:2900 region" root@127.0.0.1's password: {"count": 1,"regions": [{"id": 2,"start_key": "","end_key": "","epoch": {"conf_ver": 128,"version": 9},"peers": [{"id": 65,"store_id": 28},{"id": 66,"store_id": 11},{"id": 70,"store_id": 31},{"id": 71,"store_id": 4},{"id": 75,"store_id": 6}],"leader": {"id": 70,"store_id": 31},"approximate_size": 4986}] }Connection to 127.0.0.1 closed. [root@centos7 ~]#man ssh 查看-t參數的含義如下:
-t Force pseudo-terminal allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful,e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.#強制偽終端分配。 這可用于在遠程機器上執行任意基于屏幕的程序,這非常有用,例如 實現菜單服務時。 多個 -t 選項強制分配 tty,即使 ssh 沒有本地 tty。總結
以上是生活随笔為你收集整理的ssh 执行远程命令卡住问题解决的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 火狐导出书签_如何导出/备份Firefo
- 下一篇: 真的能月入过万,长期稳定操作-steam