Created
September 27, 2018 15:25
-
-
Save mostlylikeable/f604861d15fe2109e86648d2327bc8cc to your computer and use it in GitHub Desktop.
test sftp connection
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 characters
| @Grab(group='com.jcraft', module='jsch', version='0.1.46') | |
| import com.jcraft.jsch.* | |
| java.util.Properties config = new java.util.Properties() | |
| config.StrictHostKeyChecking = "no" | |
| JSch ssh = new JSch() | |
| Session session = ssh.getSession(user, host, port) | |
| session.config = config | |
| session.password = password | |
| session.connect() | |
| def sftp = session.openChannel("sftp") | |
| sftp.connect() | |
| println "${sftp.ls(".")}" | |
| sftp.disconnect() | |
| session.disconnect() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment