1

Eclipse で SSHJ をテストすると、すべて問題ないようです。しかし、Maven shade プラグインを使用して SSHJ をパッケージ化すると、次のエラーが発生します。

Exception in thread "main" net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods
at net.schmizz.sshj.SSHClient.auth(SSHClient.java:217)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:316)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:365)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:295)
at no.f12.SshRepository.executeTaskOnHost(SshRepository.java:23)
at no.f12.SshService.serviceCommand(SshService.java:22)
at no.f12.App.main(App.java:29)

追加する

Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());

エラーメッセージを次のように変更します。

Exception in thread "main" net.schmizz.sshj.transport.TransportException: Unable to reach a settlement: [] and [aes128-ctr, aes192-ctr, aes256-ctr, arcfour256, arcfour128, aes128-gcm@openssh.com, aes256-gcm@openssh.com, aes128-cbc, 3des-cbc, blowfish-cbc, cast128-cbc, aes192-cbc, aes256-cbc, arcfour, rijndael-cbc@lysator.liu.se]
at net.schmizz.sshj.transport.Proposal.firstMatch(Proposal.java:165)
at net.schmizz.sshj.transport.Proposal.negotiate(Proposal.java:147)
at net.schmizz.sshj.transport.KeyExchanger.gotKexInit(KeyExchanger.java:239)
at net.schmizz.sshj.transport.KeyExchanger.handle(KeyExchanger.java:364)
at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:478)
at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:127)
at net.schmizz.sshj.transport.Decoder.received(Decoder.java:195)
at net.schmizz.sshj.transport.Reader.run(Reader.java:72)

これを回避する方法はありますか?

なぜshadeを使用したいのかについての背景...私は、Javaの使用と小さなユーティリティの配布が非常に簡単になるところまで到達しようとしています。だから私はこれを使って本当に実行可能なjarを作成します: https://github.com/brianm/really-executable-jars-maven-plugin。これにより、1 つの実行可能ファイルを作成して配布し、ユーザーのパスに追加することができます。Go がすべての依存関係を含む 1 つのバイナリ ファイルを持っているのと少し似ています。

4

3 に答える 3

1

機能する可能性がある別のアプローチは、JRE 拡張ライブラリに bouncycastle を追加することです。

たとえば、ホストの「$JAVA_HOME/jre/lib/ext/」フォルダに「bcprov-jdk15on-1.49.jar」を配置します。

于 2014-08-14T14:43:46.953 に答える
1

私はこの正確な問題を抱えていました。私は最終的に、すべてを大きな「uberjar」に入れることをあきらめました。

代わりに、maven-assembly-plugin を使用してすべての jar をアセンブルし、それらを抽出して実行するためにクラスパスに追加します (例: 'java -cp all-needed-libs/* com.company.MainClass')。

于 2014-04-16T06:36:24.843 に答える
0

jar に署名する必要があります。Javax.security で必要です。同様の問題が発生し、テストからのスタックトレースがあります:

Cannot init Cipher factory: blowfish-cbc
java.lang.SecurityException: JCE cannot authenticate the provider BC
    at javax.crypto.Cipher.getInstance(Cipher.java:642)
    at javax.crypto.Cipher.getInstance(Cipher.java:580)
    at net.schmizz.sshj.common.SecurityUtils.getCipher(SecurityUtils.java:96)
    at net.schmizz.sshj.transport.cipher.BaseCipher.init(BaseCipher.java:88)
    ....
Caused by: java.util.jar.JarException: file:/test-jar-with-dependencies.jar has unsigned entries - library.properties
    at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:462)
    at javax.crypto.JarVerifier.verifyJars(JarVerifier.java:322)
    at javax.crypto.JarVerifier.verify(JarVerifier.java:250)
    at javax.crypto.JceSecurity.verifyProviderJar(JceSecurity.java:161)
    at javax.crypto.JceSecurity.getVerificationResult(JceSecurity.java:187)
    at javax.crypto.Cipher.getInstance(Cipher.java:638)
    at javax.crypto.Cipher.getInstance(Cipher.java:580)
    at net.schmizz.sshj.common.SecurityUtils.getCipher(SecurityUtils.java:96)
    at net.schmizz.sshj.transport.cipher.BaseCipher.init(BaseCipher.java:88)
    at net.schmizz.sshj.DefaultConfig.initCipherFactories(DefaultConfig.java:152)
    at net.schmizz.sshj.DefaultConfig.<init>(DefaultConfig.java:107)
于 2014-01-03T22:26:41.523 に答える