-
-
Save jbontech/1c431ee9a073aafc6d6d50215497c7a6 to your computer and use it in GitHub Desktop.
Revisions
-
chilicat renamed this gist
Sep 8, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
chilicat renamed this gist
Sep 8, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
chilicat created this gist
Sep 8, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ repositories { mavenCentral() } configurations { sshAntTask } dependencies { sshAntTask 'org.apache.ant:ant-jsch:1.9.2' } ant.taskdef( name: 'scp', classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp', classpath: configurations.sshAntTask.asPath) ant.taskdef( name: 'ssh', classname: 'org.apache.tools.ant.taskdefs.optional.ssh.SSHExec', classpath: configurations.sshAntTask.asPath) task scpAndScpTest() << { // Create a new file for each execution to make // sure that execution doesn't fails in case // idententy of host has been changed. def knownHosts = File.createTempFile("knownhosts", "txt") def user = 'root' def host = '10.129.184.44' def privateKey = file('keys/myKey') try { // Example to copy files to a remote host. ant.scp( file: file("build.gradle"), todir: "${user}@${host}:~", keyfile: privateKey, trust: true, knownhosts: knownHosts ) // Example to execute a command on the remote host. ant.ssh( host: host, username: user, keyfile: privateKey, trust: true, knownhosts: knownHosts, command: "ls /" ) } finally { knownHosts.delete() } }