【问题标题】:How do I write a shell file to type in a password under macOS?如何在 macOS 下编写一个 shell 文件来输入密码?
【发布时间】:2017-12-14 00:11:17
【问题描述】:

我正在开发一个简单的应用程序,它会自动 ssh 进入我的 iPhone 并运行一些命令。问题是 ssh 命令询问密码,我不确定如何编写 shell 文件,以便它自动输入该密码。我现在的代码如下所示:

ssh root@192.168.1.19
<here should be a code to type in the root password>
nimbus help
<some other commands>

Nimbus 是我通过 ssh 运行来远程控制手机的应用。

【问题讨论】:

标签: ios macos shell ssh passwords


【解决方案1】:

正确的方法可能是使用 key-based authentication 并将正确的 SSH 密钥添加到您的 ssh-agent

如果这不可能,或者您绝对想使用基于密码的身份验证,您可以使用sshpass

您必须手动安装它,或者,如果您使用 Homebrew,则在 http://git.io/sshpass.rb 添加自定义公式。

Homebrew 不会正式打包:

我们不会添加 sshpass,因为它使 SSH 新手用户很容易 破坏 SSH 的安全性。

所以要小心。

【讨论】:

    猜你喜欢
    • 2020-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-18
    • 1970-01-01
    • 2021-04-24
    • 1970-01-01
    相关资源
    最近更新 更多