ant - 输入 sshexec 的密码
我在公共服务器上有一个可供多个用户使用的 Ant 脚本。我想将密码安全地输入到脚本中并将其用于多个目标。以下代码通过输入获取密码,但该变量未传递给 sshexec 任务。
这会起作用还是有更好的方法?
<target name="get_password">
<input message="Enter Your Password:>" addproperty="password">
<handler classname="org.apache.tools.ant.input.SecureInputHandler" />
</input>
</target>
<target name="create_tmp_dir">
<sshexec host="${host}"
username="${username}"
password="${password}"
command="mkdir ${tmp_dir}" />
</target>
I have an ant script on a public server available to multiple users. I want to input a password into a script securely and use it for multiple targets. The following code gets a password with input, but the variable is not being passed to the sshexec task.
Will this work or is there a better way to do it?
<target name="get_password">
<input message="Enter Your Password:>" addproperty="password">
<handler classname="org.apache.tools.ant.input.SecureInputHandler" />
</input>
</target>
<target name="create_tmp_dir">
<sshexec host="${host}"
username="${username}"
password="${password}"
command="mkdir ${tmp_dir}" />
</target>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧......我发现我晚了一年,但对于新来者来说,这就是我解决问题的方法。
我的目标是以 root 身份执行命令而不泄露我的密码(显然)
最后我在我的服务器中的 ~/become-root.sh 中创建了一个 bash 脚本,如下所示
如果您调用执行命令任务,您现在可以运行命令为 sudo (假设您的用户是 sudoer)
希望这有帮助!
Ok...I see that I am a year late but for new comers this is how I solved the problem.
My goal was to execute a command as root without revealing my password (obviously)
Finally I've created a bash script in ~/become-root.sh in my server that looked like this
If you call execute-command task you can now run commands as sudo (assuming that your user is sudoer)
Hope this helps!