diff --git a/src/test/java/com/hierynomus/sshj/IntegrationTest.java b/src/test/java/com/hierynomus/sshj/IntegrationTest.java index 0d95d4c3..223f9f3b 100644 --- a/src/test/java/com/hierynomus/sshj/IntegrationTest.java +++ b/src/test/java/com/hierynomus/sshj/IntegrationTest.java @@ -15,29 +15,35 @@ */ package com.hierynomus.sshj; -import net.schmizz.sshj.DefaultConfig; -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 static org.hamcrest.MatcherAssert.assertThat; import java.io.File; 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 { + @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 public void shouldConnect() throws IOException { SSHClient sshClient = new SSHClient(new DefaultConfig()); - sshClient.addHostKeyVerifier(new PromiscuousVerifier()); - sshClient.connect("127.0.0.1", 2222); - sshClient.authPublickey("sickp", "src/test/resources/id_rsa"); + 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("192.168.99.100", 2222); + sshClient.authPublickey("sshj", "src/test/resources/id_rsa"); assertThat("Is connected", sshClient.isAuthenticated()); } } diff --git a/src/test/resources/Dockerfile b/src/test/resources/Dockerfile index 0c0867ec..93e13301 100644 --- a/src/test/resources/Dockerfile +++ b/src/test/resources/Dockerfile @@ -1,8 +1,14 @@ 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 + +ADD test-container/ssh_host_ecdsa_key /etc/ssh/ssh_host_ecdsa_key +ADD test-container/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub + RUN \ - echo "root:sunshine" | chpasswd && \ - adduser -D -s /bin/ash sickp && \ - passwd -u sickp && \ - chown -R sickp:sickp /home/sickp + 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 diff --git a/src/test/resources/test-container/ssh_host_ecdsa_key b/src/test/resources/test-container/ssh_host_ecdsa_key new file mode 100644 index 00000000..cac0cbe7 --- /dev/null +++ b/src/test/resources/test-container/ssh_host_ecdsa_key @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIOpOBFjqe0hjK/hs4WZ3dZqnzanq1L3/JbvV1TCkbe4ToAoGCCqGSM49 +AwEHoUQDQgAEVzkrS7Yj0nXML7A3mE08YDthfBR/ZbyYJDIq1vTzcqs6KTaCT529 +swNXWLHO+mbHviZcRiI57ULXHZ1emom/Jw== +-----END EC PRIVATE KEY----- diff --git a/src/test/resources/test-container/ssh_host_ecdsa_key.pub b/src/test/resources/test-container/ssh_host_ecdsa_key.pub new file mode 100644 index 00000000..9b7f7995 --- /dev/null +++ b/src/test/resources/test-container/ssh_host_ecdsa_key.pub @@ -0,0 +1 @@ +ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFc5K0u2I9J1zC+wN5hNPGA7YXwUf2W8mCQyKtb083KrOik2gk+dvbMDV1ixzvpmx74mXEYiOe1C1x2dXpqJvyc= root@404b27be2bf4 \ No newline at end of file