From 7a884d09387cd165984f16ee28edecfd9580f61f Mon Sep 17 00:00:00 2001 From: Iger Date: Sun, 3 Dec 2017 19:10:08 +0200 Subject: [PATCH 01/15] - Experimenting with travis --- .travis.yml | 10 +++++++++- .../java/com/hierynomus/sshj/IntegrationTest.java | 12 ++++++++---- src/test/resources/Dockerfile | 8 ++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 src/test/resources/Dockerfile diff --git a/.travis.yml b/.travis.yml index 8300ef05..48f62ca0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,15 @@ language: java dist: trusty -sudo: false +sudo: required +services: + - docker + +before_install: +- docker build -t sshj/test-sshd . +- docker run -d -p 127.0.0.1:2222:22 sshj/test-sshd +- docker ps -a + before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock diff --git a/src/test/java/com/hierynomus/sshj/IntegrationTest.java b/src/test/java/com/hierynomus/sshj/IntegrationTest.java index 8ee1e709..0972c0ec 100644 --- a/src/test/java/com/hierynomus/sshj/IntegrationTest.java +++ b/src/test/java/com/hierynomus/sshj/IntegrationTest.java @@ -18,6 +18,10 @@ 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; @@ -28,12 +32,12 @@ import static org.hamcrest.MatcherAssert.assertThat; public class IntegrationTest { - @Test @Ignore // Should only be enabled for testing against VM + @Test // Should only be enabled for testing against VM public void shouldConnect() 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"); + sshClient.addHostKeyVerifier(new PromiscuousVerifier()); + sshClient.connect("192.168.99.100", 2222); + sshClient.authPublickey("sickp", "src/test/resources/id_rsa.ppk"); assertThat("Is connected", sshClient.isAuthenticated()); } } diff --git a/src/test/resources/Dockerfile b/src/test/resources/Dockerfile new file mode 100644 index 00000000..0c0867ec --- /dev/null +++ b/src/test/resources/Dockerfile @@ -0,0 +1,8 @@ +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 +RUN \ + echo "root:sunshine" | chpasswd && \ + adduser -D -s /bin/ash sickp && \ + passwd -u sickp && \ + chown -R sickp:sickp /home/sickp + From c4552d5f3daf510e5c7b6ab4ad37023a1ba806bc Mon Sep 17 00:00:00 2001 From: Iger Date: Sun, 3 Dec 2017 19:18:21 +0200 Subject: [PATCH 02/15] - fix ip for online testing --- src/test/java/com/hierynomus/sshj/IntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/hierynomus/sshj/IntegrationTest.java b/src/test/java/com/hierynomus/sshj/IntegrationTest.java index 0972c0ec..854a63ec 100644 --- a/src/test/java/com/hierynomus/sshj/IntegrationTest.java +++ b/src/test/java/com/hierynomus/sshj/IntegrationTest.java @@ -36,7 +36,7 @@ public class IntegrationTest { public void shouldConnect() throws IOException { SSHClient sshClient = new SSHClient(new DefaultConfig()); sshClient.addHostKeyVerifier(new PromiscuousVerifier()); - sshClient.connect("192.168.99.100", 2222); + sshClient.connect("127.0.0.1", 2222); sshClient.authPublickey("sickp", "src/test/resources/id_rsa.ppk"); assertThat("Is connected", sshClient.isAuthenticated()); } From 47d73a9381b1747c27e48fc1076be2782c045f58 Mon Sep 17 00:00:00 2001 From: Iger Date: Sun, 3 Dec 2017 19:31:31 +0200 Subject: [PATCH 03/15] - account for different working dir --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 48f62ca0..3468f25a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ services: - docker before_install: -- docker build -t sshj/test-sshd . +- docker build -t sshj/test-sshd ./src/test/resources/ - docker run -d -p 127.0.0.1:2222:22 sshj/test-sshd - docker ps -a From 663f118d0f2af9d81a53dfa03030d47b4946cc3a Mon Sep 17 00:00:00 2001 From: Iger Date: Sun, 3 Dec 2017 19:36:20 +0200 Subject: [PATCH 04/15] - yaml-yaml --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3468f25a..125b40bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,9 @@ services: - docker before_install: -- docker build -t sshj/test-sshd ./src/test/resources/ -- docker run -d -p 127.0.0.1:2222:22 sshj/test-sshd -- docker ps -a + - docker build -t sshj/test-sshd ./src/test/resources/ + - docker run -d -p 127.0.0.1:2222:22 sshj/test-sshd + - docker ps -a before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock From 8454cf1a0cfaeb112893d8e63458424520dff63a Mon Sep 17 00:00:00 2001 From: Iger Date: Sun, 3 Dec 2017 19:44:05 +0200 Subject: [PATCH 05/15] - double before_install --- .travis.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 125b40bc..ac749d3e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,11 +5,6 @@ sudo: required services: - docker -before_install: - - docker build -t sshj/test-sshd ./src/test/resources/ - - docker run -d -p 127.0.0.1:2222:22 sshj/test-sshd - - docker ps -a - before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock @@ -25,6 +20,8 @@ jdk: before_install: - pip install --user codecov + - docker build -t sshj/test-sshd ./src/test/resources/ + - docker run -p 127.0.0.1:2222:22 sshj/test-sshd after_success: - codecov From a014567c9e87db3184ec6db2438e5869e2f880c3 Mon Sep 17 00:00:00 2001 From: Iger Date: Sun, 3 Dec 2017 20:05:26 +0200 Subject: [PATCH 06/15] - still -d --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ac749d3e..a85a50e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ jdk: before_install: - pip install --user codecov - docker build -t sshj/test-sshd ./src/test/resources/ - - docker run -p 127.0.0.1:2222:22 sshj/test-sshd + - docker run -d -p 127.0.0.1:2222:22 sshj/test-sshd after_success: - codecov From 0e981f76565bc3fe6692bb185ba3f7de795075fa Mon Sep 17 00:00:00 2001 From: Iger Date: Sun, 3 Dec 2017 20:25:26 +0200 Subject: [PATCH 07/15] - try common format --- src/test/java/com/hierynomus/sshj/IntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/hierynomus/sshj/IntegrationTest.java b/src/test/java/com/hierynomus/sshj/IntegrationTest.java index 854a63ec..0d95d4c3 100644 --- a/src/test/java/com/hierynomus/sshj/IntegrationTest.java +++ b/src/test/java/com/hierynomus/sshj/IntegrationTest.java @@ -37,7 +37,7 @@ public class IntegrationTest { 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.ppk"); + sshClient.authPublickey("sickp", "src/test/resources/id_rsa"); assertThat("Is connected", sshClient.isAuthenticated()); } } From a0f1aa7e2c02c12733c36593072a89c2b4654adb Mon Sep 17 00:00:00 2001 From: Iger Date: Sun, 3 Dec 2017 22:08:06 +0200 Subject: [PATCH 08/15] - Fixed server keys - Use sshj branding --- .../com/hierynomus/sshj/IntegrationTest.java | 32 +++++++++++-------- src/test/resources/Dockerfile | 16 +++++++--- .../test-container/ssh_host_ecdsa_key | 5 +++ .../test-container/ssh_host_ecdsa_key.pub | 1 + 4 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 src/test/resources/test-container/ssh_host_ecdsa_key create mode 100644 src/test/resources/test-container/ssh_host_ecdsa_key.pub 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 From 2b62492cafa1cce834f72ba5efea8dd2d94f3589 Mon Sep 17 00:00:00 2001 From: Iger Date: Sun, 3 Dec 2017 22:11:29 +0200 Subject: [PATCH 09/15] - grr, ip --- src/test/java/com/hierynomus/sshj/IntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/hierynomus/sshj/IntegrationTest.java b/src/test/java/com/hierynomus/sshj/IntegrationTest.java index 223f9f3b..1fefa5a9 100644 --- a/src/test/java/com/hierynomus/sshj/IntegrationTest.java +++ b/src/test/java/com/hierynomus/sshj/IntegrationTest.java @@ -42,7 +42,7 @@ public class IntegrationTest { public void shouldConnect() throws IOException { SSHClient sshClient = new SSHClient(new DefaultConfig()); 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.connect("127.0.0.1", 2222); sshClient.authPublickey("sshj", "src/test/resources/id_rsa"); assertThat("Is connected", sshClient.isAuthenticated()); } From 9d697ede120dd5b1b898fb90912d970a8e7e4c13 Mon Sep 17 00:00:00 2001 From: Iger Date: Sun, 3 Dec 2017 22:28:02 +0200 Subject: [PATCH 10/15] - minor improvements --- .../com/hierynomus/sshj/IntegrationTest.java | 20 ++++++++++++++++--- src/test/resources/Dockerfile | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/hierynomus/sshj/IntegrationTest.java b/src/test/java/com/hierynomus/sshj/IntegrationTest.java index 1fefa5a9..89f66c7f 100644 --- a/src/test/java/com/hierynomus/sshj/IntegrationTest.java +++ b/src/test/java/com/hierynomus/sshj/IntegrationTest.java @@ -26,9 +26,14 @@ import org.junit.Test; import net.schmizz.sshj.DefaultConfig; import net.schmizz.sshj.SSHClient; import net.schmizz.sshj.transport.verification.OpenSSHKnownHosts; +import net.schmizz.sshj.userauth.UserAuthException; public class IntegrationTest { + private static final int DOCKER_PORT = 2222; + private static final String USERNAME = "sshj"; + private final static String SERVER_IP = System.getProperty("serverIP", "127.0.0.1"); + @Test @Ignore // Should only be enabled for testing against VM public void shouldConnectVM() throws IOException { SSHClient sshClient = new SSHClient(new DefaultConfig()); @@ -38,12 +43,21 @@ public class IntegrationTest { assertThat("Is connected", sshClient.isAuthenticated()); } - @Test // Should only be enabled for testing against VM + @Test public void shouldConnect() throws IOException { SSHClient sshClient = new SSHClient(new DefaultConfig()); 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.authPublickey("sshj", "src/test/resources/id_rsa"); + sshClient.connect(SERVER_IP, DOCKER_PORT); + sshClient.authPublickey(USERNAME, "src/test/resources/id_rsa"); assertThat("Is connected", sshClient.isAuthenticated()); } + + @Test(expected = UserAuthException.class) + public void shouldFailWithWrongKey() throws IOException { + SSHClient sshClient = new SSHClient(new DefaultConfig()); + 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(SERVER_IP, DOCKER_PORT); + sshClient.authPublickey(USERNAME, "src/test/resources/id_dsa"); + } + } diff --git a/src/test/resources/Dockerfile b/src/test/resources/Dockerfile index 93e13301..ab836e27 100644 --- a/src/test/resources/Dockerfile +++ b/src/test/resources/Dockerfile @@ -1,4 +1,5 @@ FROM sickp/alpine-sshd:7.5 + ADD id_rsa.pub /home/sshj/.ssh/authorized_keys ADD test-container/ssh_host_ecdsa_key /etc/ssh/ssh_host_ecdsa_key From 73bc785ab4328ad7a35c9e9c64ad9b9d165914cb Mon Sep 17 00:00:00 2001 From: Iger Date: Sun, 3 Dec 2017 22:40:41 +0200 Subject: [PATCH 11/15] - eh? --- .../com/hierynomus/sshj/IntegrationTest.java | 33 +++++++++++++++---- src/test/resources/Dockerfile | 17 +++------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/test/java/com/hierynomus/sshj/IntegrationTest.java b/src/test/java/com/hierynomus/sshj/IntegrationTest.java index 89f66c7f..b0adfddd 100644 --- a/src/test/java/com/hierynomus/sshj/IntegrationTest.java +++ b/src/test/java/com/hierynomus/sshj/IntegrationTest.java @@ -25,13 +25,15 @@ import org.junit.Test; import net.schmizz.sshj.DefaultConfig; import net.schmizz.sshj.SSHClient; +import net.schmizz.sshj.transport.TransportException; import net.schmizz.sshj.transport.verification.OpenSSHKnownHosts; +import net.schmizz.sshj.transport.verification.PromiscuousVerifier; import net.schmizz.sshj.userauth.UserAuthException; public class IntegrationTest { private static final int DOCKER_PORT = 2222; - private static final String USERNAME = "sshj"; + private static final String USERNAME = "sickp"; private final static String SERVER_IP = System.getProperty("serverIP", "127.0.0.1"); @Test @Ignore // Should only be enabled for testing against VM @@ -44,20 +46,37 @@ public class IntegrationTest { } @Test - public void shouldConnect() throws IOException { + public void shouldAcceptCorrectKey() throws IOException { SSHClient sshClient = new SSHClient(new DefaultConfig()); 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(SERVER_IP, DOCKER_PORT); + assertThat("Is connected", sshClient.isConnected()); + } + + @Test(expected = TransportException.class) + public void shouldDeclineWrongKey() throws IOException { + SSHClient sshClient = new SSHClient(new DefaultConfig()); + sshClient.addHostKeyVerifier("d4:6a:a9:52:05:ab:b5:48:dd:73:60:18:0c:3a:f0:a3"); + sshClient.connect(SERVER_IP, DOCKER_PORT); + } + + @Test + public void shouldConnect() throws IOException { + SSHClient sshClient = getConnectedClient(); sshClient.authPublickey(USERNAME, "src/test/resources/id_rsa"); - assertThat("Is connected", sshClient.isAuthenticated()); + assertThat("Is authenitcated", sshClient.isAuthenticated()); } @Test(expected = UserAuthException.class) public void shouldFailWithWrongKey() throws IOException { - SSHClient sshClient = new SSHClient(new DefaultConfig()); - 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(SERVER_IP, DOCKER_PORT); - sshClient.authPublickey(USERNAME, "src/test/resources/id_dsa"); + getConnectedClient().authPublickey(USERNAME, "src/test/resources/id_dsa"); } + private SSHClient getConnectedClient() throws IOException { + SSHClient sshClient = new SSHClient(new DefaultConfig()); + sshClient.addHostKeyVerifier(new PromiscuousVerifier()); + sshClient.connect(SERVER_IP, DOCKER_PORT); + + return sshClient; + } } diff --git a/src/test/resources/Dockerfile b/src/test/resources/Dockerfile index ab836e27..0c0867ec 100644 --- a/src/test/resources/Dockerfile +++ b/src/test/resources/Dockerfile @@ -1,15 +1,8 @@ FROM sickp/alpine-sshd:7.5 - -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 - +ADD https://raw.githubusercontent.com/Igerly/sshj/master/src/test/resources/id_rsa.pub /home/sickp/.ssh/authorized_keys 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 + echo "root:sunshine" | chpasswd && \ + adduser -D -s /bin/ash sickp && \ + passwd -u sickp && \ + chown -R sickp:sickp /home/sickp From 7cb1f8b11ce795949ecc68e8dfd11426de558f32 Mon Sep 17 00:00:00 2001 From: Iger Date: Sun, 3 Dec 2017 22:49:29 +0200 Subject: [PATCH 12/15] - switch username back --- .../com/hierynomus/sshj/IntegrationTest.java | 2 +- src/test/resources/Dockerfile | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/test/java/com/hierynomus/sshj/IntegrationTest.java b/src/test/java/com/hierynomus/sshj/IntegrationTest.java index b0adfddd..861b1a46 100644 --- a/src/test/java/com/hierynomus/sshj/IntegrationTest.java +++ b/src/test/java/com/hierynomus/sshj/IntegrationTest.java @@ -33,7 +33,7 @@ import net.schmizz.sshj.userauth.UserAuthException; public class IntegrationTest { private static final int DOCKER_PORT = 2222; - private static final String USERNAME = "sickp"; + private static final String USERNAME = "sshj"; private final static String SERVER_IP = System.getProperty("serverIP", "127.0.0.1"); @Test @Ignore // Should only be enabled for testing against VM diff --git a/src/test/resources/Dockerfile b/src/test/resources/Dockerfile index 0c0867ec..9bdc08f2 100644 --- a/src/test/resources/Dockerfile +++ b/src/test/resources/Dockerfile @@ -1,8 +1,15 @@ 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 https://raw.githubusercontent.com/Igerly/sshj/master/src/test/resources/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 + From 64a2a4f77910aaa421bd1b8a3f2538f5d4c3c836 Mon Sep 17 00:00:00 2001 From: Iger Date: Sun, 3 Dec 2017 22:55:18 +0200 Subject: [PATCH 13/15] - orly? --- src/test/resources/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/Dockerfile b/src/test/resources/Dockerfile index 9bdc08f2..49b41e90 100644 --- a/src/test/resources/Dockerfile +++ b/src/test/resources/Dockerfile @@ -1,6 +1,6 @@ FROM sickp/alpine-sshd:7.5 -ADD https://raw.githubusercontent.com/Igerly/sshj/master/src/test/resources/id_rsa.pub /home/sshj/.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 From d0daa2c12feb660748192bb08ab21b3307f9c955 Mon Sep 17 00:00:00 2001 From: Iger Date: Sun, 3 Dec 2017 23:00:40 +0200 Subject: [PATCH 14/15] - desperation --- src/test/resources/id_rsa.pub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/id_rsa.pub b/src/test/resources/id_rsa.pub index 6c50ee23..5ef5ef4a 100644 --- a/src/test/resources/id_rsa.pub +++ b/src/test/resources/id_rsa.pub @@ -1 +1 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAoZ9l6Tkm2aL1tSBy2yw4xU5s8BE9MfqS/4J7DzvsYJxF6oQmTIjmStuhH/CT7UjuDtKXdXZUsIhKtafiizxGO8kHSzKDeitpth2RSr8ddMzZKyD6RNs7MfsgjA3UTtrrSrCXEY6O43S2cnuJrWzkPxtwxaQ3zOvDbS2tiulzyq0VzYmuhA/a4CyuQtJBuu+P2oqmu6pU/VB6IzONpvBvYbNPsH1WDmP7zko5wHPihXPCliztspKxS4DRtOZ7BGXyvg44UmIy0Kf4jOkaBV/eCCA4qH7ZHz71/5ceMOpszPcNOEmLGGYhwI+P3OuGMpkrSAv1f8IY6R8spZNncP6UaQ== no-passphrase +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAoZ9l6Tkm2aL1tSBy2yw4xU5s8BE9MfqS/4J7DzvsYJxF6oQmTIjmStuhH/CT7UjuDtKXdXZUsIhKtafiizxGO8kHSzKDeitpth2RSr8ddMzZKyD6RNs7MfsgjA3UTtrrSrCXEY6O43S2cnuJrWzkPxtwxaQ3zOvDbS2tiulzyq0VzYmuhA/a4CyuQtJBuu+P2oqmu6pU/VB6IzONpvBvYbNPsH1WDmP7zko5wHPihXPCliztspKxS4DRtOZ7BGXyvg44UmIy0Kf4jOkaBV/eCCA4qH7ZHz71/5ceMOpszPcNOEmLGGYhwI+P3OuGMpkrSAv1f8IY6R8spZNncP6UaQ== no-passphrase \ No newline at end of file From 4045d5a7ef62d3973b9beafdc272ee94690ed1cc Mon Sep 17 00:00:00 2001 From: Iger Date: Sun, 3 Dec 2017 23:10:56 +0200 Subject: [PATCH 15/15] - One more time --- src/test/resources/Dockerfile | 1 + src/test/resources/id_rsa.pub | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/resources/Dockerfile b/src/test/resources/Dockerfile index 49b41e90..b306ac8c 100644 --- a/src/test/resources/Dockerfile +++ b/src/test/resources/Dockerfile @@ -9,6 +9,7 @@ RUN \ echo "root:smile" | chpasswd && \ adduser -D -s /bin/ash sshj && \ passwd -u sshj && \ + chmod 600 /home/sshj/.ssh/authorized_keys && \ 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/id_rsa.pub b/src/test/resources/id_rsa.pub index 5ef5ef4a..6c50ee23 100644 --- a/src/test/resources/id_rsa.pub +++ b/src/test/resources/id_rsa.pub @@ -1 +1 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAoZ9l6Tkm2aL1tSBy2yw4xU5s8BE9MfqS/4J7DzvsYJxF6oQmTIjmStuhH/CT7UjuDtKXdXZUsIhKtafiizxGO8kHSzKDeitpth2RSr8ddMzZKyD6RNs7MfsgjA3UTtrrSrCXEY6O43S2cnuJrWzkPxtwxaQ3zOvDbS2tiulzyq0VzYmuhA/a4CyuQtJBuu+P2oqmu6pU/VB6IzONpvBvYbNPsH1WDmP7zko5wHPihXPCliztspKxS4DRtOZ7BGXyvg44UmIy0Kf4jOkaBV/eCCA4qH7ZHz71/5ceMOpszPcNOEmLGGYhwI+P3OuGMpkrSAv1f8IY6R8spZNncP6UaQ== no-passphrase \ No newline at end of file +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAoZ9l6Tkm2aL1tSBy2yw4xU5s8BE9MfqS/4J7DzvsYJxF6oQmTIjmStuhH/CT7UjuDtKXdXZUsIhKtafiizxGO8kHSzKDeitpth2RSr8ddMzZKyD6RNs7MfsgjA3UTtrrSrCXEY6O43S2cnuJrWzkPxtwxaQ3zOvDbS2tiulzyq0VzYmuhA/a4CyuQtJBuu+P2oqmu6pU/VB6IzONpvBvYbNPsH1WDmP7zko5wHPihXPCliztspKxS4DRtOZ7BGXyvg44UmIy0Kf4jOkaBV/eCCA4qH7ZHz71/5ceMOpszPcNOEmLGGYhwI+P3OuGMpkrSAv1f8IY6R8spZNncP6UaQ== no-passphrase