i'm trying to execute a command in a remote server with sudo like this
<target name="remote-test">
<sshexec host="${remote.host}"
username="${remote.user}"
password="${remote.pass}"
trust="true"
usepty="true"
command="sudo ls /home/myuser" />
</target>
But the server response the following:
Buildfile: build.xml
remote-test:
[sshexec] Connecting to 0.0.0.0:22
[sshexec] cmd : sudo ls /home/myuser
[sshexec] [sudo] password for myuser:
So, how i can use ant to execute a remote command with sudo?
Thanks :)
Yes, maybe it can be duplicated like this:
How to pass the password to su/sudo/ssh without overriding the TTY?
But anyway, one solution to this problems is like says in the most voted answer of the
<target name="remote-test-jboss">
<sshexec host="${remote.host}"
username="${remote.user}"
password="${remote.pass}"
command="echo ${remote.pass}| sudo -S ls /home/myserver"
trust="true"
/>
</target>
The -S parameter is for read from standart input.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With