- Fixed server keys

- Use sshj branding
This commit is contained in:
Iger
2017-12-03 22:08:06 +02:00
parent 0e981f7656
commit a0f1aa7e2c
4 changed files with 36 additions and 18 deletions

View File

@@ -15,29 +15,35 @@
*/ */
package com.hierynomus.sshj; package com.hierynomus.sshj;
import net.schmizz.sshj.DefaultConfig; import static org.hamcrest.MatcherAssert.assertThat;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.transport.verification.OpenSSHKnownHosts;
import net.schmizz.sshj.transport.verification.PromiscuousVerifier;
import net.schmizz.sshj.userauth.keyprovider.KeyProvider;
import net.schmizz.sshj.userauth.keyprovider.KeyProviderUtil;
import org.junit.Ignore;
import org.junit.Test;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import static org.hamcrest.MatcherAssert.assertThat; import org.junit.Ignore;
import org.junit.Test;
import net.schmizz.sshj.DefaultConfig;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.transport.verification.OpenSSHKnownHosts;
public class IntegrationTest { public class IntegrationTest {
@Test @Ignore // Should only be enabled for testing against VM
public void shouldConnectVM() throws IOException {
SSHClient sshClient = new SSHClient(new DefaultConfig());
sshClient.addHostKeyVerifier(new OpenSSHKnownHosts(new File("/Users/ajvanerp/.ssh/known_hosts")));
sshClient.connect("172.16.37.147");
sshClient.authPublickey("jeroen");
assertThat("Is connected", sshClient.isAuthenticated());
}
@Test // Should only be enabled for testing against VM @Test // Should only be enabled for testing against VM
public void shouldConnect() throws IOException { public void shouldConnect() throws IOException {
SSHClient sshClient = new SSHClient(new DefaultConfig()); SSHClient sshClient = new SSHClient(new DefaultConfig());
sshClient.addHostKeyVerifier(new PromiscuousVerifier()); sshClient.addHostKeyVerifier("d3:6a:a9:52:05:ab:b5:48:dd:73:60:18:0c:3a:f0:a3"); // test-containers/ssh_host_ecdsa_key's fingerprint
sshClient.connect("127.0.0.1", 2222); sshClient.connect("192.168.99.100", 2222);
sshClient.authPublickey("sickp", "src/test/resources/id_rsa"); sshClient.authPublickey("sshj", "src/test/resources/id_rsa");
assertThat("Is connected", sshClient.isAuthenticated()); assertThat("Is connected", sshClient.isAuthenticated());
} }
} }

View File

@@ -1,8 +1,14 @@
FROM sickp/alpine-sshd:7.5 FROM sickp/alpine-sshd:7.5
ADD https://raw.githubusercontent.com/Igerly/sshj/master/src/test/resources/id_rsa.pub /home/sickp/.ssh/authorized_keys ADD id_rsa.pub /home/sshj/.ssh/authorized_keys
RUN \
echo "root:sunshine" | chpasswd && \ ADD test-container/ssh_host_ecdsa_key /etc/ssh/ssh_host_ecdsa_key
adduser -D -s /bin/ash sickp && \ ADD test-container/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub
passwd -u sickp && \
chown -R sickp:sickp /home/sickp RUN \
echo "root:smile" | chpasswd && \
adduser -D -s /bin/ash sshj && \
passwd -u sshj && \
chmod 600 /etc/ssh/ssh_host_ecdsa_key && \
chmod 644 /etc/ssh/ssh_host_ecdsa_key.pub && \
chown -R sshj:sshj /home/sshj

View File

@@ -0,0 +1,5 @@
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIOpOBFjqe0hjK/hs4WZ3dZqnzanq1L3/JbvV1TCkbe4ToAoGCCqGSM49
AwEHoUQDQgAEVzkrS7Yj0nXML7A3mE08YDthfBR/ZbyYJDIq1vTzcqs6KTaCT529
swNXWLHO+mbHviZcRiI57ULXHZ1emom/Jw==
-----END EC PRIVATE KEY-----

View File

@@ -0,0 +1 @@
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFc5K0u2I9J1zC+wN5hNPGA7YXwUf2W8mCQyKtb083KrOik2gk+dvbMDV1ixzvpmx74mXEYiOe1C1x2dXpqJvyc= root@404b27be2bf4