mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
feat: use entrypoint to create user account and copy ssh key
This commit is contained in:
1 parent
261c6fc029
commit
be22a121c8
4 files changed
+26
-14
No files matched your search
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
USERNAME=commander
|
||||
|
||||
if ! id -u ${USERNAME} >/dev/null 2>&1; then
|
||||
adduser --disabled-password --gecos '' --shell /bin/zsh ${USERNAME} && \
|
||||
mkdir -p /home/${USERNAME}/.ssh && \
|
||||
cp /ssh_key.pub /home/${USERNAME}/.ssh/authorized_keys && \
|
||||
chmod 600 /home/${USERNAME}/.ssh/authorized_keys && \
|
||||
chmod 700 /home/${USERNAME}/.ssh && \
|
||||
chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.ssh
|
||||
fi
|
||||
|
||||
mkdir /run/sshd
|
||||
echo "Starting SSH server"
|
||||
/usr/sbin/sshd -D -e
|
||||
Reference in new issue
Block a user