-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cac): add script to configure alpine linux vm image for vedv
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -eu | ||
|
||
readonly DEFAULT_USER="${DEFAULT_USER:-vedv}" | ||
readonly DEFAULT_PASS="${DEFAULT_PASS:-vedv}" | ||
|
||
# add user | ||
adduser --disabled-password "$DEFAULT_USER" | ||
echo "${DEFAULT_USER}:${DEFAULT_PASS}" | chpasswd | ||
|
||
# change root password | ||
echo "root:${DEFAULT_PASS}" | chpasswd | ||
|
||
# enable community repository | ||
readonly COMMUNITY_REPO="$(grep 'alpine/v.*/community' /etc/apk/repositories | sed 's/\//\\\//g')" | ||
readonly ENABLED_COMMUNITY_REPO="$(echo "$COMMUNITY_REPO/" | sed 's/^#//')" | ||
sed -i "s/${COMMUNITY_REPO}/${ENABLED_COMMUNITY_REPO}" /etc/apk/repositories | ||
|
||
# install sudo | ||
apk add sudo | ||
# configure sudoers | ||
adduser "$DEFAULT_USER" wheel | ||
echo "%wheel ALL=(ALL) NOPASSWD: ALL" >/etc/sudoers.d/"${DEFAULT_USER}-nopasswd" | ||
|
||
# install openssh | ||
apk add openssh | ||
# configure sshd | ||
sed -i \ | ||
-e 's/^#\?\s*PermitRootLogin .*/PermitRootLogin yes/' \ | ||
-e 's/^#\?\s*PasswordAuthentication .*/PasswordAuthentication yes/' \ | ||
/etc/ssh/sshd_config | ||
|
||
service sshd restart |