diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2022-05-21 14:02:54 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2022-05-21 14:02:54 +0200 |
commit | a3a8dfaf6669b61f289ced571a14e8d0067e5d68 (patch) | |
tree | 4b1e749ccb65739bddab41f4e8d0e5fc43c9d1c3 /tests/setup_sshd_test | |
parent | 6f2bd755a7e639c957a216bf8d1965ecbfb62d0e (diff) | |
download | alpine-conf-a3a8dfaf6669b61f289ced571a14e8d0067e5d68.zip |
setup-sshd: refactor
Ask for ssh key in separate question unless PermitRootLogin was set to
no.
Diffstat (limited to 'tests/setup_sshd_test')
-rwxr-xr-x | tests/setup_sshd_test | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/tests/setup_sshd_test b/tests/setup_sshd_test index 19bbda3..b177949 100755 --- a/tests/setup_sshd_test +++ b/tests/setup_sshd_test @@ -6,7 +6,8 @@ init_tests \ setup_sshd_empty \ setup_sshd_dropbear \ setup_sshd_openssh \ - setup_sshd_interactive + setup_sshd_interactive_openssh_nologin \ + setup_sshd_interactive_openssh_prohibitpass setup_sshd_usage_body() { test_usage setup-sshd @@ -42,7 +43,7 @@ setup_sshd_openssh_body() { grep 'ssh-id FOOBAR' root/.ssh/authorized_keys || atf_fail "failed to wget ssh key" } -setup_sshd_interactive_body() { +setup_sshd_interactive_openssh_nologin_body() { init_env mkdir -p etc/ssh echo "PermitRootLogin foobar" > etc/ssh/sshd_config @@ -54,8 +55,33 @@ setup_sshd_interactive_body() { -e empty \ -o match:"Which ssh server" \ -o match:"Allow root ssh login" \ + -o not-match:"Enter ssh key" \ -o match:"apk add.* openssh" \ setup-sshd < answers grep '^PermitRootLogin no$' etc/ssh/sshd_config || atf_fail "did not set PermitRootLogin" } +setup_sshd_interactive_openssh_prohibitpass_body() { + init_env + mkdir -p etc/ssh + echo "PermitRootLogin foobar" > etc/ssh/sshd_config + ( + echo "openssh" + echo "" + echo "gh user" + echo "" + ) >answers + export WGETCONTENT="key from github" + atf_check -s exit:0 \ + -e empty \ + -o match:"Which ssh server" \ + -o match:"apk add.* openssh" \ + -o match:"Allow root ssh login.*\[prohibit-password\]" \ + -o match:"Enter ssh key" \ + -o match:"Enter ssh key.*github.com.*user.keys" \ + setup-sshd <answers + grep '^PermitRootLogin prohibit-password$' etc/ssh/sshd_config \ + || atf_fail "did not set PermitRootLogin" + grep "$WGETCONTENT" root/.ssh/authorized_keys +} + |