Skip to content

Instantly share code, notes, and snippets.

@mostlylikeable
Created September 27, 2018 15:25
Show Gist options
  • Select an option

  • Save mostlylikeable/f604861d15fe2109e86648d2327bc8cc to your computer and use it in GitHub Desktop.

Select an option

Save mostlylikeable/f604861d15fe2109e86648d2327bc8cc to your computer and use it in GitHub Desktop.
test sftp connection
@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