我在Windows机器上,我需要编写一些使用SSH连接到远程Solaris机器的Java代码,然后可以在其上执行命令并获取其输出,但我在验证方面遇到了一些麻烦.(我正在使用SSHJ 0.8.1)
这是连接和启动会话的代码:
public void init(String address, int portNumber, String hostKeyVerifier) throws IOException {
client = new SSHClient();
client.getConnection().setTimeout(300);
client.addHostKeyVerifier(hostKeyVerifier);
client.connect(address, portNumber);
client.authPassword("user", "password");
session = client.startSession();
}
Run Code Online (Sandbox Code Playgroud)
我希望这会导致工作连接,因为尝试使用相同的代码(尽管使用不同的主机密钥验证程序,地址,端口和凭据)连接到Apache Karaf的实例.相反,这是我得到的输出:
16:27:58.029 [main] INFO n.schmizz.sshj.common.SecurityUtils - BouncyCastle not registered, using the default JCE provider
16:27:58.159 [main] INFO n.s.sshj.transport.TransportImpl - Client identity string: SSH-2.0-SSHJ_0_8_1_SNAPSHOT
16:27:58.159 [main] INFO n.s.sshj.transport.TransportImpl - Server identity string: SSH-2.0-Sun_SSH_2.2
16:27:58.159 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<kex done>> to `null`
16:27:58.159 [main] DEBUG n.s.sshj.transport.KeyExchanger - Sending SSH_MSG_KEXINIT
16:27:58.169 [main] …Run Code Online (Sandbox Code Playgroud) 我希望将一些提交从一个存储库移动到另一个存储库,并且我想保留原始提交、日期和提交消息等,而不是将整个事情压缩在一起。git format-patch master明白了,每次提交都会生成一个 .patch 文件,但我在应用它们时遇到了一些麻烦(我陷入了第一次提交)。
git apply <patch file name>干净地应用更改,没有冲突或任何东西,但当然它不会创建我想要的提交。
git am --committer-date-is-author-date -3 < <patch file name>另一方面,失败且没有明确的解决方法:
Applying: <original commit message>
error: patch failed: war/WEB-INF/web.xml:162
error: war/WEB-INF/web.xml: patch does not apply
<more files listed, all of them ones that I've modified in the commit; newly created files are not listed>
error: Did you hand edit your patch?
It does not apply to blobs recorded in its index.
hint: Use 'git am --show-current-patch' to see the …Run Code Online (Sandbox Code Playgroud) 我正在使用 OpenJDK 8(从https://jdk.java.net/java-se-ri/8下载并解压,添加到 PATH 中),并且遇到了证书错误。
经过调查,我意识到 cacerts 存在问题。
运行keytool -list -keystore cacerts返回错误:keytool error: java.lang.Exception: Keystore file does not exist: cacerts,
但运行keytool -list -keystore "C:\development\exec\cmd\jdk8\jre\lib\security\cacerts"
给我一份实际证书的列表。JAVA_HOME确实指向
C:\development\exec\cmd\jdk8并且PATH确实有一个条目%JAVA_HOME%\bin。我应该如何配置 java 以在正确的位置查找 cacerts?
java -version返回以下内容:
openjdk version "1.8.0_40"
OpenJDK Runtime Environment (build 1.8.0_40-b25)
OpenJDK Client VM (build 25.40-b25, mixed mode)
Run Code Online (Sandbox Code Playgroud) 我的C代码似乎出现故障,无法将长长的数字乘以输出结果,我不能为我的生活找出原因.
这是罪魁祸首代码:
#include "stdio.h"
int main()
{
unsigned long long primes[] = {199453LL, 200723LL, 203317LL, 205103LL, 206603LL, 208057LL, 210323LL, 210961LL, 212827LL, 214237LL, 215693LL, 216319LL};
unsigned long long numbers[6];
int i;
printf("Calculating the numbers to factor!\n");
printf("Size of long: %i\n", sizeof(long));
printf("Size of long long: %i\n", sizeof(long long));
for (i = 0; i < 6; i++)
{
numbers[i] = primes[i]*primes[11-i];
printf("%ld*%ld = %ld\n", primes[i], primes[11-i], numbers[i]);
printf("Result is %ld\n",numbers[i]);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是我编译并运行它时的输出(我在Linux上使用gcc版本4.8.2)
Calculating the numbers to factor!
Size of …Run Code Online (Sandbox Code Playgroud)