2 # This script assumes a server with key-based root access into one of
3 # key-based access only to a new non-root account plom.
5 # CAUTION: This is optimized for a *fresh* setup. It will overwrite any
6 # old /etc/ssh/sshd_config.
8 # Dependencies: ssh, scp, properly configured sshd_config file in reach.
13 # Location of an sshd_config with "PermitRootLogin no" and
14 # "PasswordAuthentication no".
15 linkable_files_dir="${config_tree_prefix}/etc_files/server"
16 system_path_sshd_config='/etc/ssh/sshd_config'
17 local_path_sshd_config="${linkable_files_dir}${system_path_sshd_config}"
19 expect_n_args 1 "(server)" "$@"
22 # So we're only asked once …
26 # # This will be used to log-in as root from plom account.
27 # echo 'Asking for new root password.'
28 # ssh root@"${server}" "passwd"
30 # # Set up plom's ~/.ssh/authorized_keys from root's.
31 # ssh root@"${server}" 'useradd -m plom'
32 # ssh root@"${server}" 'mkdir /home/plom/.ssh'
33 # ssh root@"${server}" 'chown plom:plom /home/plom/.ssh'
34 # ssh root@"${server}" 'cp /root/.ssh/authorized_keys /home/plom/.ssh/'
35 # ssh root@"${server}" 'chown plom:plom /home/plom/.ssh/authorized_keys'
37 # Set up SSH config and remove direct SSH login to root.
38 scp "${local_path_sshd_config}" root@"${server}":"${system_path_sshd_config}"
39 ssh root@"${server}" 'rm -rf /root/.ssh && service ssh restart'