blob: c82e394c0109b7290dfc2391401bce1984d6430c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/usr/bin/env bash
# If already running from root, no need for sudo
SUDO=""
[ $(id -u) -ne 0 ] && SUDO="sudo"
function os_pkgs_install()
{
${SUDO} apt-get -y update
# Install required packages
${SUDO} apt-get install -y git wget iputils-ping iproute2 unzip openssh-server openssh-client tk sudo
}
function os_cfg()
{
[ ! -f /etc/ssh/ssh_host_rsa_key ] && ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
[ ! -f /etc/ssh/ssh_host_ecdsa_key ] && ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''
[ ! -f /etc/ssh/ssh_host_ed25519_key ] && ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ''
[ ! -d /var/run/sshd ] && mkdir -p /var/run/sshd
USER_NAME="opnfv"
USER_PWD="opnfv"
ROOT_USER="root"
useradd -m -d /home/${USER_NAME} -s /bin/bash -U ${USER_NAME}
echo "${USER_NAME}:${USER_PWD}" | chpasswd
echo "${ROOT_USER}:${USER_PWD}" | chpasswd
usermod -aG sudo ${USER_NAME}
echo "%sudo ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USER_NAME}
}
function cleanup()
{
${SUDO} apt-get autoremove -y
${SUDO} apt-get clean all
${SUDO} rm -rf /var/cache/apt
}
os_pkgs_install
os_cfg
cleanup
|