org.springframework.integration.sftp
Class SftpSession
java.lang.Object
org.springframework.integration.sftp.SftpSession
public class SftpSession
- extends java.lang.Object
There are many ways to create a SftpSession
just as there are many ways to SSH into a remote system.
You may use a username and password, you may use a username and private key, you may use a username and a private key with a password, etc.
This object represents the connection to the remote server, and to use it you must provide it with all the components you'd normally provide an
incantation of the ssh
command.
Constructor Summary |
SftpSession(java.lang.String userName,
java.lang.String hostName,
java.lang.String userPassword,
int port,
java.lang.String knownHostsFile,
java.io.InputStream knownHostsInputStream,
java.lang.String privateKey,
java.lang.String pvKeyPassPhrase)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SftpSession
public SftpSession(java.lang.String userName,
java.lang.String hostName,
java.lang.String userPassword,
int port,
java.lang.String knownHostsFile,
java.io.InputStream knownHostsInputStream,
java.lang.String privateKey,
java.lang.String pvKeyPassPhrase)
throws java.lang.Exception
- Parameters:
userName
- the name of the account being logged into.hostName
- this should be the host. I found values like foo.com
work, where
http://foo.com
don't.userPassword
- if you are not using key based authentication, then you are likely being prompted
for a password each time you login. This is that password. It is not the
passphrase for the private key!port
- the default is 22, and if you specify N<0 for this value we'll default it to 22knownHostsFile
- this is the known hosts file. If you don't specify it, jsch does some magic to work
without your specification. If you have it in a non well-known location, however,
this property is for you. An example: /home/user/.ssh/known_hosts
knownHostsInputStream
- this is the known hosts file. If you don't specify it, jsch does some magic to work
without your specification. If you have it in a non well-known location, however,
this property is for you. An example: /home/user/.ssh/known_hosts
. Note
that you may specify this or the #knownHostsFile - not both!privateKey
- this is usually used when you want passwordless automation (obviously, for this
integration it's useless since this lets you specify a password once, anyway, but
still good to have if required). This file might be ~/.ssh/id_dsa, or a
.pem
for your remote server (for example, on EC2)pvKeyPassPhrase
- sometimes, to be extra secure, the private key itself is extra encrypted. In order
to surmount that, we need the private key passphrase. Specify that here.
- Throws:
java.lang.Exception
- thrown if any of a myriad of scenarios plays out
getChannel
public com.jcraft.jsch.ChannelSftp getChannel()
getSession
public com.jcraft.jsch.Session getSession()
start
public void start()
throws java.lang.Exception
- Throws:
java.lang.Exception