7
任何人都可以給我一個私鑰/公鑰認證的例子sshj?ssh私鑰/公鑰認證示例
在sshj什麼是命令行等效的,
ssh -i /path/to/mykey.private [email protected]
我試過(處理省略錯誤),
final SSHClient ssh = new SSHClient();
ssh.loadKnownHosts();
ssh.connect("host");
ssh.authPublickey("username", "/path/to/mykey.private");
final Session session = ssh.startSession();
...
,但在日誌報表一看,
DEBUG net.schmizz.sshj.SSHClient - Attempting to load key from: /path/to/mykey.private
WARN net.schmizz.sshj.SSHClient - Could not load keys due to: {}
net.schmizz.sshj.common.SSHException: No provider available forUnknown key file
at net.schmizz.sshj.SSHClient.loadKeys(SSHClient.java:482) ~[sshj-0.3.0.jar:na]
...
Exception in thread "main" 10:49:55.943 [reader] DEBUG
net.schmizz.sshj.transport.Reader - Stopping
net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods
謝謝, Everett
我回答了類似的問題[這裏](http://stackoverflow.com/a/15800383/311525)用一個例子連接到AWS實例與他們提供的.pem文件。這並不像我希望的那樣直截了當。 – Scott 2013-04-04 00:16:44