我正在尝试通过 Linux 机器上的 ssh 从诺基亚路由器获取一些信息。
如果我这样做,ssh 可以正常工作:
我可以输入密码,登录,运行命令。
但是,当我执行以下操作时,它会立即断开我的连接:
ssh -v [email protected] 'show time'
Verbose output:
debug1: Next authentication method: password
[email protected]'s password:
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LC_PAPER = en_US.UTF-8
debug1: Sending env LC_ADDRESS = en_US.UTF-8
debug1: Sending env LC_MONETARY = en_US.UTF-8
debug1: Sending env LC_NUMERIC = en_US.UTF-8
debug1: Sending env LC_TELEPHONE = en_US.UTF-8
debug1: Sending env LC_IDENTIFICATION = en_US.UTF-8
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending env LC_MEASUREMENT = en_US.UTF-8
debug1: Sending env LC_TIME = en_US.UTF-8
debug1: Sending env LC_NAME = en_US.UTF-8
debug1: Sending command: show time
debug1: channel 0: free: client-session, nchannels 1
Connection to 10.0.0.1 closed by remote host.
Transferred: sent 2088, received 1840 bytes, in 0.0 seconds
Bytes per second: sent 488193.7, received 430209.0
debug1: Exit status -1
如果我使用期望脚本连接,发送密码,然后发送命令,它工作正常。
有什么问题?
感谢所有的评论。
最后,我最终使用了 expect,因为我正在使用 bash 脚本来连接和提取信息。