SshSource allows you to connect to a remote SSH server and download one or more paths. Paths can be either a directory or a file. You can specify as many directories or paths as you want to download and SshSource will send those InputStreams through the Pipeline. The SshSource rows will have the following keys:
ssh( host )
.knownHosts( knownHostFile )
.authPass( username, password )
.download( "/some/path/file.txt", "/some/other/path/file2.txt", "/other/directory")
.into()
...
.go()
Using public key authentication:
ssh( host, 2222 )
.knownHosts( knownHostFile )
.identity( username, keyFile, passphrase )
.download( "/some/path/file.txt", "/some/other/path/file2.txt", "/other/directory")
.into()
...
.go()
The known hosts file can be created using the following:
ssh-keyscan -H -t rsa example.org >> known_hosts
Constructor and description |
---|
SshSource
(java.lang.String host, int port) |
Type Params | Return Type | Name and description |
---|---|---|
|
SshSource |
authPass(java.lang.String username, java.lang.String password) Authenticate with a username and password. |
|
void |
doStart(Pipeline pipeline) |
|
SshSource |
download(java.lang.String... remotePath) One or more remote paths you wish to download from the SFTP server. |
|
void |
downloadPath(Pipeline pipeline, com.jcraft.jsch.ChannelSftp channel, java.lang.String path) |
|
SshSource |
enableStrictHostCheck(boolean enable) Can be used to disable the known host checking, but this has serious security implications which need to be carefully considered before doing this. |
|
SshSource |
identity(java.lang.String username, java.io.File identity, java.lang.String passphrase) This uses a SSH key pair to authenticate the given username. |
|
SshSource |
knownHosts(java.io.File knownHostsFile) A file containing the list of known hosts the client will use to authorize the connection to the server. |
|
static SshSource |
ssh(java.lang.String remoteHost, int port = 22) Returns a SshSource for file transfer over sftp connecting the given remote host over the given TCP port. |
Authenticate with a username and password.
username
- The user name to authenticatepassword
- The password for the given user nameOne or more remote paths you wish to download from the SFTP server. These can be individual files or directories. If a directory is specified all files within the directory are downloaded (recursively).
remotePath
- one or more remote paths you wish to download, file or directory is acceptable Can be used to disable the known host checking, but this has serious security
implications which need to be carefully considered before doing this. If you're
having problems with not being able to connect an safer option is to run the following:
ssh-keyscan -H -t rsa example.org >> known_hosts
Then use the file you created as the known host file.
enable
- if true enable strict host checking else disable strict host checkingThis uses a SSH key pair to authenticate the given username. This uses public-key authentication of SSH. The given passphrase is used to decrypt the private key in the identity file.
username
- the username to authenticat asidentity
- the key file that holds the private key of the identity you wish to usepassphrase
- the passphrase that is used to protect the given identity fileA file containing the list of known hosts the client will use to authorize the connection to the server.
knownHostsFile
- The file of known hosts the client is willing to connect to.Returns a SshSource for file transfer over sftp connecting the given remote host over the given TCP port.
remoteHost
- The remote host to connect toport
- the remote TCP port to use to connectGroovy Documentation