4 # Location auf a sshd_config with "PermitRootLogin no" and
5 # "PasswordAuthentication no".
6 config_tree_prefix="${HOME}/public_repos/config/buster"
7 linkable_files_dir="${config_tree_prefix}/etc_files/server"
8 system_path_sshd_config='/etc/ssh/sshd_config'
9 local_path_sshd_config="${linkable_files_dir}${system_path_sshd_config}"
11 # Ensure we have a server name as argument.
13 echo "Need server as argument."
18 # So we're only asked once …
22 # This will be used to log-in as root from plom account.
23 echo 'Asking for new root password.'
24 ssh root@"${server}" "passwd"
26 # Set up plom's ~/.ssh/authorized_keys from root's.
27 ssh root@"${server}" 'useradd -m plom'
28 ssh root@"${server}" 'mkdir /home/plom/.ssh'
29 ssh root@"${server}" 'chown plom:plom /home/plom/.ssh'
30 ssh root@"${server}" 'cp /root/.ssh/authorized_keys /home/plom/.ssh/'
31 ssh root@"${server}" 'chown plom:plom /home/plom/.ssh/authorized_keys'
33 # Set up SSH config and remove direct SSH login to root.
34 scp "${local_path_sshd_config}" root@"${server}":"${system_path_sshd_config}"
35 ssh root@"${server}" 'rm -rf /root/.ssh && service ssh restart'