Ant:如何避免 SSH 密码?
问题
- 我们有一个完全控制的服务器
- 我们有一个又长又复杂的 shell 脚本,通过 SCP 和 SSH 与该服务器交互
- 我们有一个运行脚本
简化示例的 Ant 目标:
<target name="run-script">
<exec executable="/path/to/script_that_runs_ssh_cmds.sh" />
</target>
该目标失败,但出现以下异常:
ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory
问题
经过一番研究后,我认为这可以通过生成公钥/私钥对来解决。这样,ssh 命令就不必提示输入密码。假设此解决方案可行,您如何才能使系统上的 SSH 调用使用密钥而不是提示输入密码?是否可以进行设置,使我们团队中的任何人都可以从他们的笔记本电脑成功运行 Ant 目标?
注意:我们都运行 OS X 10.6 (Leopard),并且物理连接到与服务器相同的 LAN。
Problem
- We have a server over which we have FULL control
- We have a long, complicated shell script that interacts with this server via SCP and SSH
- We have an Ant Target that runs the script
simplified example:
<target name="run-script">
<exec executable="/path/to/script_that_runs_ssh_cmds.sh" />
</target>
This target fails with the following exception:
ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory
Question
After researching a bit, I think this can be fixed by generating public/private key pairs. That way, the ssh command doesn't have to prompt for passwords. Assuming this solution will work, how do you go about making it so that SSH calls on the system use keys in lieu of prompting for passwords? Is it possible to set this up in a way that anyone on our team can run the Ant target successfully from their laptop?
Note: We're all running OS X 10.6 (Leopard) and physically connected to the same LAN as the server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需将私钥安装在
~/.ssh
下,ssh
将自动查找该目录并使用您安装的密钥。在服务器端,将公钥添加到
~/.ssh/authorized_keys
You can just install the private key under
~/.ssh
andssh
will automatically look into that directory and use the key you installed.In the server side, add the public key to
~/.ssh/authorized_keys