blob: 0b52dfe499bd4626dffc6ac050241211ea9b9689 [file] [log] [blame]
Chase Qi7c3f8892019-02-21 17:19:32 +08001#!/bin/sh -ex
2
3TEST_DIR=$(dirname "$(realpath "$0")")
4# shellcheck disable=SC1090
5. "${TEST_DIR}/../../lib/sh-test-lib"
6
7# On unsupported distros, installation will be skipped by default.
8install_deps openssh-server
9
10# Add id_rsa.pub key sent by host to authorized_keys.
11pub_key=$(grep "pub_key" /tmp/lava_multi_node_cache.txt | awk -F"=" '{print $NF}')
12mkdir -p ~/.ssh/
13echo "ssh-rsa ${pub_key} fuego-lava" > ~/.ssh/authorized_keys
14chmod 600 ~/.ssh/authorized_keys
15
16# Enabled root login.
17if ! grep "^PermitRootLogin yes" /etc/ssh/sshd_config; then
18 # Enable root login.
19 sed -i 's/^# *PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
20 sed -i 's/^ *PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
21
22 # Restart ssh.
23 dist_name
24 # shellcheck disable=SC2154
25 case "${dist}" in
26 debian|ubuntu|fedora|centos)
27 systemctl restart ssh
28 systemctl status ssh
29 ;;
30 *)
31 warning_msg "Unknown distro: ${dist}, attempting to restart ssh..."
32 /etc/init.d/ssh restart || true
33 service ssh restart || true
34 ;;
35 esac
36 sleep 3
37fi
38