help!!! ssh使用privatekey连接问题
来源: 互联网 发布时间:2016-02-29
本文导语: 我使用ganymed-ssh2-build210.jar包通过scp命令发送文件,连接的程序如下: private Connection getOpenedConnection(String host, String username, String password ) throws IOException { Connection conn = new Connectio...
我使用ganymed-ssh2-build210.jar包通过scp命令发送文件,连接的程序如下:
private Connection getOpenedConnection(String host, String username,
String password ) throws IOException
{
Connection conn = new Connection(host);
conn.connect(); // make sure the connection is opened
boolean isAuthenticated = conn.authenticateWithPublicKey(username, new File("C:\ssh\id_rsa"), null);
if (isAuthenticated == false)
{
throw new IOException("Authentication failed.");
}
return conn;
}
得到的异常是java.io.IOException: Publickey authentication failed.
这里的PublicKey生成过程应该怎样生成,我的发送方是windows,接收文件方是unix,这里的rsa key pair应该怎样生成?应该是在unix(文件接收方)生成key pair还是在windows(文件发送方)?
private Connection getOpenedConnection(String host, String username,
String password ) throws IOException
{
Connection conn = new Connection(host);
conn.connect(); // make sure the connection is opened
boolean isAuthenticated = conn.authenticateWithPublicKey(username, new File("C:\ssh\id_rsa"), null);
if (isAuthenticated == false)
{
throw new IOException("Authentication failed.");
}
return conn;
}
得到的异常是java.io.IOException: Publickey authentication failed.
这里的PublicKey生成过程应该怎样生成,我的发送方是windows,接收文件方是unix,这里的rsa key pair应该怎样生成?应该是在unix(文件接收方)生成key pair还是在windows(文件发送方)?
|
因为是普通文本,所以Linux和Windows下生成都可以
|
。。。楼上几个好无聊 这又不是散分帖
|
up
|
UP
|
JF
|
JF
|
JF
|
jf
|
jf
|
JF