将密码传递给“su"从 ant 控制 sshexec [英] Passing a password to "su" command over sshexec from ant

查看:32
本文介绍了将密码传递给“su"从 ant 控制 sshexec的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以将密码传递给 linux su" 命令?我正在尝试使用 sshexec 和 Ant 自动化部署.作为其中的一部分,我需要执行su"命令,但我找不到给它密码的方法.su 命令没有像 sudo 那样的 -S 开关.我已经尝试在 sshexec 上使用 commandResource 和 input 属性,但我只是得到一个su:抱歉".

Is there any way to pass a password to the linux "su" command? I'm attempting to automate a deployment using sshexec and Ant. As part of that I need to execute the "su" command, but I can find no way to give it a password. The su command does not have the -S switch like sudo. I've tried using the commandResource and input properties on sshexec, but I just get an "su: Sorry" back.

在任何人认为我是之前,我没有将密码存储在文件中.根据提示输入密码,在 Ant 内存中生​​成要执行的脚本.

Before anyone thinks I am, I am not storing passwords in files. The script to execute is being generated in memory in Ant based on prompting for a password.

推荐答案

不是这方面的专家,但您可能应该使用 sudo 而不是 su.以下线程可能会帮助更多 pass-password-to-su-sudo-ssh

Not an expert at this but you should probably use sudo instead of su. The following thread might help more pass-password-to-su-sudo-ssh

这篇关于将密码传递给“su"从 ant 控制 sshexec的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆