将密码传递给"su".从ant通过sshexec命令 [英] Passing a password to "su" command over sshexec from ant
问题描述
有什么办法可以将密码传递给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屋!