Created
July 5, 2016 06:12
-
-
Save alces/599b1bbe53b33ddbad5f32aa553e2aea to your computer and use it in GitHub Desktop.
The script demonstrates using Ant scp and sshexec tasks from Groovy
This file contains 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 characters
@GrabConfig(systemClassLoader = true) | |
@Grab('jsch:jsch') | |
@Grab('ant:ant-jsch') | |
def sshHost = '127.0.0.1' | |
def sshPort = 2200 | |
def sshUser = 'vagrant' | |
def sshPrivKey = "${System.getProperty('user.home')}/.vagrant.d/insecure_private_key" | |
def ant = new AntBuilder() | |
ant.sshexec(host: sshHost, | |
port: sshPort, | |
username: sshUser, | |
keyfile: sshPrivKey, | |
command: 'ls -l /') | |
ant.scp(file: '/etc/services', | |
todir: "${sshUser}@${sshHost}:/home/vagrant", | |
port: sshPort, | |
keyfile: sshPrivKey, | |
passphrase: '') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment