int128 / gradle-ssh-plugin

Gradle SSH Plugin
https://gradle-ssh-plugin.github.io
Apache License 2.0
318 stars 60 forks source link

executeSudo doesn't prompt for sudo password #312

Open jcarrete5 opened 6 years ago

jcarrete5 commented 6 years ago

Environment info

gradle-ssh-plugin-2.9.0 (groovy-ssh-2.9.0, jsch-0.1.53, groovy-2.4.12, java-1.8.0_144)

Description

When I try to execute the deploy task, the executeSudo method doesn't prompt for sudo password. I have tried using other solutions for getting the sudo password from the user described in #302 and #16. When I run the task I get the error org.hidetake.groovy.ssh.interaction.InteractionException: Error while stream interaction: org.hidetake.groovy.ssh.session.execution.SudoException: Failed sudo authentication on jsonet[jsonet.ddns.net:22]: Sorry, try again.

The task works fine when I set the sudoPassword in plain text but I would really like to avoid storing the sudo password in plain text somewhere.

task deploy(dependsOn: distTar) {
    description = 'Uploads the server distribution to the remote app server.'
    group = 'distribution'
    doLast {
        ssh.run {
            session(remotes.role('appServer')) {
                def targetFile = "${applicationName}-${version}.tar"
                put from: new File(new File(buildDir, "distributions"), targetFile),
                    into: "/tmp"
                executeSudo "mv /tmp/$targetFile /opt", pty: true
            }
        }
    }
}
Helios-23 commented 5 years ago

Error is Still occurring as specified above. Any Updates or work arounds?