forked from binlab/docker-bastion
-
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.
- Loading branch information
1 parent
47add70
commit 2e61149
Showing
3 changed files
with
21 additions
and
15 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
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
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 |
---|---|---|
@@ -1,16 +1,20 @@ | ||
#!/bin/sh | ||
while IFS= read -r line | ||
do | ||
IFS=';' read -r username publickey <<EOF | ||
# Escape into (subshell), because we're modifying the IFS | ||
( | ||
while IFS= read -r line | ||
# Yet another (subshell), because we're modifying the IFS we're using | ||
do ( | ||
IFS=':' read -r username publickey <<EOF | ||
$line | ||
EOF | ||
adduser -D -h "/home/${username}" -s /bin/ash -g "${username} service" \ | ||
-G "${GROUP}" "${username}" | ||
adduser -D -h "/home/${username}" -s /bin/ash -g "${username} service" \ | ||
-G "${BASTION_GROUP}" "${username}" | ||
|
||
mkdir -p "/home/${username}/.ssh" | ||
echo "${publickey}" > "/home/${username}/.ssh/authorized_keys" | ||
mkdir -p "/home/${username}/.ssh" | ||
echo "${publickey}" > "/home/${username}/.ssh/authorized_keys" | ||
|
||
chown -R "${username}":"${GROUP}" "/home/${username}/.ssh" | ||
chmod 700 "/home/${username}/.ssh" | ||
chmod 600 "/home/${username}/.ssh/authorized_keys" | ||
done <"${SETUP_KEYS_PATH}" | ||
chown -R "${username}":"${BASTION_GROUP}" "/home/${username}/.ssh" | ||
chmod 700 "/home/${username}/.ssh" | ||
chmod 600 "/home/${username}/.ssh/authorized_keys" | ||
) done <"${SETUP_KEYS_PATH}" | ||
) |