Tag: sftp

spring integration sftp mainframe:写文件失败; 嵌套exception为3:权限被拒绝

我正在尝试使用spring integration sftp:outbound-gateway将文件sft到大型机:这是配置: 哪里 remote.upload.filename.credit.fmpl=/!DTS4.UP.G3TRF.S60304 remote.upload.directory=/ 我得到例外: Caused by: org.springframework.integration.MessagingException: Failed to write to ‘//!DTS4.UP.G3TRF.S60304’ while uploading the file at org.springframework.integration.file.remote.RemoteFileTemplate.sendFileToRemoteDirectory(RemoteFileTemplate.java:392) at org.springframework.integration.file.remote.RemoteFileTemplate.access$500(RemoteFileTemplate.java:56) at org.springframework.integration.file.remote.RemoteFileTemplate$1.doInSession(RemoteFileTemplate.java:213) … 46 more Caused by: org.springframework.core.NestedIOException: failed to write file; nested exception is 3: Permission denied at org.springframework.integration.sftp.session.SftpSession.write(SftpSession.java:158) at org.springframework.integration.file.remote.RemoteFileTemplate.sendFileToRemoteDirectory(RemoteFileTemplate.java:385) … 48 more Caused by: 3: Permission denied at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2629) […]

在Java中使用SFTP,如何将文件从一个文件夹传输到另一个文件夹?

我有一个带有两个文件夹的简单目录 – 在SFTP_1文件夹中,我有一个位图图像。 而SFTP_2文件夹只是一个空文件夹。 Java是否有要使用的本机SFTP库? 当我搜索时,我只在网上找到了一个名为JSch的图书馆 我将如何开始运行此示例? 任何提示赞赏,谢谢!

JSch:存储在hdfs上的私钥的addIdentity

我需要从hadoop集群连接到sftp服务器。 我想知道是否有办法从存储在hdfs中的私钥加载身份。 实际上似乎JSch对象只接受本地路径: try { String privateKeyPath = “hdfs://namenode:8020/path/to/privatekey”; // need this one to be an hdfs path JSch jsch = new JSch(); jsch.addIdentity(privateKeyPath); // [..] } catch (Exception ex) { // [..] } 任何想法?

使用Jcraft通过SFTP传输文件

项目清单 我可以编写一个java程序来通过SFTP传输文件。 但是,这将包含一个带有可执行命令的脚本。 这可以通过Jcraft实现吗? 比方说,示例脚本文件是这样的: cd pub ascii get filename.txt put otherFile.txt bye

使用jsch库复制sftp中的文件

import com.jcraft.jsch.*; public class App { public static void main(String args[]) { JSch jsch = new JSch(); Session session = null; try { session = jsch.getSession(“Username”, “Host”, PORT NO); session.setConfig(“StrictHostKeyChecking”, “no”); session.setPassword(“Password”); session.connect(); Channel channel = session.openChannel(“sftp”); channel.connect(); ChannelSftp sftpChannel = (ChannelSftp) channel; sftpChannel.get(“remotefile.txt”, “localfile.txt”); sftpChannel.exit(); session.disconnect(); } catch (JSchException e) { e.printStackTrace(); } catch […]

如何使用Java SFTP Library JSch将文件从一个目录传输到另一个目录?

我需要使用JSch库编写文件传输程序。 我有一个带有两个文件夹的简单目录 – 在SFTP_1文件夹中,我有一个位图图像。 而SFTP_2文件夹只是一个空文件夹。 我的目标是使用SFTP从SFTP_1到SFTP_2传输映像。 到目前为止,这是我的代码: import com.jcraft.jsch.*; import java.awt.Desktop; import java.nio.channels.Channel; public class FileTransfer { public FileTransfer() { super(); } public static void main (String[] args) { FileTransfer fileTransfer = new FileTransfer(); JSch jsch = new JSch(); try { String host = “127.0.0.1”; int port = 22; String user = “user”; Session session […]

使用java连接到SFTP

我需要帮助连接到SFTP服务器? 有人有工作代码吗? 我找到了这样的东西 package test.JSch; import com.jcraft.jsch.*; public class TestJSch { public static void main(String args[]) { JSch jsch = new JSch(); Session session = null; try { session = jsch.getSession(“USSERNAME”, “HOST”, 22); //session.setConfig(“StrictHostKeyChecking”, “no”); session.setPassword(“PASSWORD”); System.out.println(“1”); session.connect(); System.out.println(“2”); Channel channel = session.openChannel(“sftp”); System.out.println(“3”); channel.connect(); System.out.println(“4”); ChannelSftp sftpChannel = (ChannelSftp) channel; sftpChannel.get(“remotefile.txt”, “localfile.txt”); sftpChannel.exit(); session.disconnect(); […]

使用JSCH在远程服务器上获取MD5校验和

我正在编写一个应用程序,其中要求是将文件从远程SFTP服务器传输到本地计算机,反之亦然。 在文件传输期间,我想确保在传输过程中没有数据包丢失和损坏。因此想法是在传输之前在远程文件(驻留在sftp服务器上)上运行MD5校验和,然后启动传输过程。 传输完成后,在本地文件上运行md5并比较两个校验和。 我使用JSCH连接到sftp服务器,代码在java.But我不知道如何在驻留在SFTP服务器上的远程文件上运行md5。我的代码必须在传输之前在远程文件上运行MD5 place.Any想法如何实现这一点请。

当密码包含@时,“期望/遵循URI中的主机名”exception

我正在尝试将本地系统文件复制到服务器 package classes; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.util.Properties; import org.apache.commons.vfs.FileObject; import org.apache.commons.vfs.FileSystemOptions; import org.apache.commons.vfs.Selectors; import org.apache.commons.vfs.impl.StandardFileSystemManager; import org.apache.commons.vfs.provider.sftp.SftpFileSystemConfigBuilder; public class SendMyFiles { public static void main(String[] args) { SendMyFiles sendMyFiles = new SendMyFiles(); String fileToFTP = “zcol_30092013.xls”; sendMyFiles.startFTP(fileToFTP); } public boolean startFTP(String fileToFTP){ Properties prop = new Properties(); InputStream in = getClass().getResourceAsStream(“/config.properties”); […]

使用Apache Mina作为模拟/内存SFTP服务器进行unit testing

我在解决如何使用Apache Mina时遇到了一些麻烦。 他们的文档对于我无能为力的大脑来说有点不足。 我在Java SFTP服务器库中看到了有用的起始代码? 我无法弄清楚的是如何使用它。 我想设置一个unit testing来检查我的sftp代码,使用Mina作为一种模拟服务器,即能够编写unit testing,如: @Before public void beforeTestSetup() { sshd = SshServer.setUpDefaultServer(); sshd.setPort(22); sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(“hostkey.ser”)); List<NamedFactory> userAuthFactories = new ArrayList<NamedFactory>(); userAuthFactories.add(new UserAuthNone.Factory()); sshd.setUserAuthFactories(userAuthFactories); sshd.setPublickeyAuthenticator(new PublickeyAuthenticator()); sshd.setCommandFactory(new ScpCommandFactory()); List<NamedFactory> namedFactoryList = new ArrayList<NamedFactory>(); namedFactoryList.add(new SftpSubsystem.Factory()); sshd.setSubsystemFactories(namedFactoryList); try { sshd.start(); } catch (Exception e) { e.printStackTrace(); } } @Test public void testGetFile() […]