mirror of
https://github.com/rancher/os.git
synced 2025-09-07 01:31:06 +00:00
Refactor build scripts
This commit is contained in:
20
images/02-console/update-ssh-keys
Executable file
20
images/02-console/update-ssh-keys
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
USERNAME=$1
|
||||
HOME_DIR=$(grep ^$USERNAME /etc/passwd | cut -f6 -d:)
|
||||
|
||||
if [ ! -d $HOME_DIR/.ssh ]; then
|
||||
mkdir -p $HOME_DIR/.ssh
|
||||
chmod 0700 $HOME_DIR/.ssh
|
||||
fi
|
||||
|
||||
if [ ! -e $HOME_DIR/.ssh/authorized_keys ]; then
|
||||
touch $HOME_DIR/.ssh/authorized_keys
|
||||
chmod 0600 $HOME_DIR/.ssh/authorized_keys
|
||||
fi
|
||||
|
||||
if ! grep -q "$2" $HOME_DIR/.ssh/authorized_keys; then
|
||||
echo "$2" >> $HOME_DIR/.ssh/authorized_keys
|
||||
fi
|
||||
|
||||
chown -R $USERNAME $HOME_DIR/.ssh
|
Reference in New Issue
Block a user