Spring DefaultSftpSessionFactory 无法连接
Spring DefaultSftpSessionFactory cannot connect
我可以使用以下方式连接到 stfp 服务器:
sftp root@44.333.22.1
然而,当我这样配置 Spring 时:
<bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<property name="host" value="44.333.22.1"/>
<property name="user" value="root"/>
<property name="port" value="22"/>
</bean>
我得到以下信息:
原因:java.lang.IllegalArgumentException:需要密码或私钥
在 org.springframework.util.Assert.isTrue(Assert.java:65)
在 org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:320)
在 org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:49)
在 org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:334)
... 还有 38 个
知道我做错了什么吗?
谢谢,
布鲁斯
我错过了私钥:
<property name="privateKey" value="classpath:id_rsa"/>
我可以使用以下方式连接到 stfp 服务器:
sftp root@44.333.22.1
然而,当我这样配置 Spring 时:
<bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<property name="host" value="44.333.22.1"/>
<property name="user" value="root"/>
<property name="port" value="22"/>
</bean>
我得到以下信息:
原因:java.lang.IllegalArgumentException:需要密码或私钥 在 org.springframework.util.Assert.isTrue(Assert.java:65) 在 org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:320) 在 org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:49) 在 org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:334) ... 还有 38 个
知道我做错了什么吗?
谢谢, 布鲁斯
我错过了私钥:
<property name="privateKey" value="classpath:id_rsa"/>