cheneydog
V2EX  ›  问与答

关于 shell、terminal 理解不清楚

  •  
  •   cheneydog · Aug 17, 2022 · 1618 views
    This topic created in 1390 days ago, the information mentioned may be changed or developed.
    使用 nodejs ,主要使用 process 和 child_process 包下的东西。
    1. 我想做一个类似 sshpass 的功能的东西。把 ssh 调起来,模拟输入密码。
    -? ssh 需要额外添加 -T 参数,不是很明白。
    -?密码总是返回错误,我确认密码是对的。

    2. 我想调起来 docker -it 的交互形式。
    docker -i 可以交互,但是所有命令都不认。
    docker -t 调不起来。the input device is not a TTY
    4 replies    2022-08-17 19:29:47 +08:00
    julyclyde
        1
    julyclyde  
       Aug 17, 2022
    shell 和 terminal 没啥关系啊。你如果说 tty 和 terminal 分不清还情有可原
    julyclyde
        2
    julyclyde  
       Aug 17, 2022
    ssh 读密码的时候是读取 /dev/tty 设备的,这样才能做到只按键盘但是不显示在屏幕上
    你如果要模拟这个,就需要做一个 pty (虚拟 tty )让 ssh 运行在里面
    apake
        3
    apake  
       Aug 17, 2022 via Android
    shell 是用户进程,terminal/tty/pty 是虚拟出来的可读写的硬件设备。 shell 读写 terminal ,从 terminal 里读的内容是人输入进去的。
    cheneydog
        4
    cheneydog  
    OP
       Aug 17, 2022
    找了个库,造假 pty ,解决了。
    https://www.npmjs.com/package/node-pty
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3033 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 52ms · UTC 14:25 · PVG 22:25 · LAX 07:25 · JFK 10:25
    ♥ Do have faith in what you're doing.