ch.ethz.ssh2.SFTPv3Client Java Examples

The following examples show how to use ch.ethz.ssh2.SFTPv3Client. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SSH2Util.java    From util with Apache License 2.0 6 votes vote down vote up
/**
 * 功能:登录
 * @author 朱志杰 QQ:862990787
 * Sep 2, 2013 9:41:45 AM
 * @param hostname ssh2的hostname
 * @param port 端口 SSH2的默认端口是22
 * @param userName 用户名
 * @param pwd 密码
 * @throws IOException 
 */
public boolean login(String hostname,int port,String userName,String pwd) throws IOException{
	/* Create a connection instance */
	conn = new Connection(hostname,port);
	/* Now connect */
	conn.connect();
	/* Authenticate.
	 * If you get an IOException saying something like
	 * "Authentication method password not supported by the server at this stage."
	 * then please check the FAQ.
	 */
	boolean isAuthenticated = conn.authenticateWithPassword(userName, pwd);
	//sftp
	sftp=new SFTPv3Client(conn);
	return isAuthenticated;
}
 
Example #2
Source File: SSHExecutor.java    From zkdoctor with Apache License 2.0 5 votes vote down vote up
/**
 * 创建目录
 *
 * @param remoteDir 待创建目录
 * @return
 */
public Result mkDir(String remoteDir) {
    try {
        SFTPv3Client sftpClient = new SFTPv3Client(conn);
        // 权限全部给创建者
        sftpClient.mkdir(remoteDir, 0700);
        return new Result(true);
    } catch (Exception e) {
        LOGGER.error("Make remote dir {} failed.", remoteDir, e);
        return new Result(e);
    }
}
 
Example #3
Source File: SSHExecutor.java    From PoseidonX with Apache License 2.0 5 votes vote down vote up
/**
 * 创建目录
 *
 * @param remoteDir 待创建目录
 * @return
 */
public Result mkDir(String remoteDir) {
    try {
        SFTPv3Client sftpClient = new SFTPv3Client(conn);
        // 权限全部给创建者
        sftpClient.mkdir(remoteDir, 0700);
        return new Result(true);
    } catch (Exception e) {
        LOGGER.error("Make remote dir {} failed.", remoteDir, e);
        return new Result(e);
    }
}