Skip to content

Instantly share code, notes, and snippets.

@int128
Created October 9, 2014 12:19
Show Gist options
  • Save int128/686c5bec0eaf4cb38b3e to your computer and use it in GitHub Desktop.
Save int128/686c5bec0eaf4cb38b3e to your computer and use it in GitHub Desktop.
Execute SSH script

Execute SSH script with groovy-ssh.

  • groovy-ssh-0.1.2
  • groovy-all-2.3.6
  • jsch-0.1.51
  • slf4j-api-1.7.7
  • logback-core-1.1.2
  • logback-classic-1.1.2
21:15:19.892 [main] INFO o.h.g.s.i.c.DefaultConnectionManager - Strict host key checking is turned off. Use only for testing purpose.
21:15:20.031 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: Connecting to localhost port 22
21:15:20.058 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: Connection established
21:15:20.089 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: Remote version string: SSH-2.0-OpenSSH_6.2
21:15:20.090 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: Local version string: SSH-2.0-JSCH-0.1.51
21:15:20.090 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
21:15:20.521 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: aes256-cbc is not available.
21:15:20.522 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: aes192-cbc is not available.
21:15:20.522 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: CheckKexes: diffie-hellman-group14-sha1
21:15:20.578 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: SSH_MSG_KEXINIT sent
21:15:20.579 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: SSH_MSG_KEXINIT received
21:15:20.579 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: server: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
21:15:20.580 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: server: ssh-rsa,ssh-dss
21:15:20.580 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: server: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
21:15:20.580 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: server: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
21:15:20.580 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: server: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
21:15:20.582 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: server: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
21:15:20.583 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: server: none,[email protected]
21:15:20.583 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: server: none,[email protected]
21:15:20.583 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: server:
21:15:20.583 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: server:
21:15:20.583 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: client: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1
21:15:20.584 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: client: ssh-rsa,ssh-dss
21:15:20.584 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
21:15:20.584 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
21:15:20.584 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
21:15:20.584 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
21:15:20.584 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: client: none
21:15:20.585 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: client: none
21:15:20.585 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: client:
21:15:20.585 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: client:
21:15:20.585 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: server->client aes128-ctr hmac-md5 none
21:15:20.586 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: kex: client->server aes128-ctr hmac-md5 none
21:15:20.597 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: SSH_MSG_KEXDH_INIT sent
21:15:20.597 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: expecting SSH_MSG_KEXDH_REPLY
21:15:20.630 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: ssh_rsa_verify: signature true
21:15:20.639 [main] INFO o.h.g.s.i.connection.JSchLogger - JSch: Permanently added 'localhost' (RSA) to the list of known hosts.
21:15:20.639 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: SSH_MSG_NEWKEYS sent
21:15:20.639 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: SSH_MSG_NEWKEYS received
21:15:20.648 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: SSH_MSG_SERVICE_REQUEST sent
21:15:20.649 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: SSH_MSG_SERVICE_ACCEPT received
21:15:20.652 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: Authentications that can continue: publickey,keyboard-interactive,password
21:15:20.652 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: Next authentication method: publickey
21:15:20.754 [main] DEBUG o.h.g.s.i.connection.JSchLogger - JSch: Authentication succeeded (publickey).
21:15:20.755 [main] INFO o.h.g.s.i.c.DefaultConnectionManager - Established a session to Remote localhost [localhost:22] via localhost:22
21:15:20.771 [main] DEBUG o.h.g.s.i.session.SessionService - Mixin extensions: [class org.hidetake.groovy.ssh.extension.SudoExecution, class org.hidetake.groovy.ssh.extension.SftpGet, class org.hidetake.groovy.ssh.extension.SftpPut]
21:15:20.823 [main] INFO o.h.g.s.i.s.DefaultSessionHandler - Execute a command (w)
21:15:20.865 [main] DEBUG o.h.g.s.i.o.DefaultOperations - Executing a command (w) with org.hidetake.groovy.ssh.api.OperationSettings(false, false, true, UTF-8, null, [class org.hidetake.groovy.ssh.extension.SudoExecution, class org.hidetake.groovy.ssh.extension.SftpGet, class org.hidetake.groovy.ssh.extension.SftpPut])
21:15:20.918 [main] INFO o.h.g.s.i.o.DefaultOperations - Channel #0 has been opened
21:15:20.982 [Connect thread localhost session] INFO o.h.g.s.i.o.DefaultOperations - 21:15 up 18 days, 20:47, 5 users, load averages: 1.45 1.63 1.58
21:15:20.983 [Connect thread localhost session] INFO o.h.g.s.i.o.DefaultOperations - USER TTY FROM LOGIN@ IDLE WHAT
21:15:21.021 [main] INFO o.h.g.s.i.o.DefaultOperations - Channel #0 has been closed with exit status 0
import static org.hidetake.groovy.ssh.Ssh.ssh
ssh.settings {
knownHosts = allowAnyHosts
}
ssh.remotes {
localhost {
host = 'localhost'
user = System.properties['user.name']
identity = new File("${System.properties['user.home']}/.ssh/id_rsa")
}
}
ssh.run {
session(ssh.remotes.localhost) {
println execute('w')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment