forked from NASP/registry
DictXiong
dcd6f0c726
This reverts commit 01bc3762b2
.
Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
Reviewed-on: NASP/registry#87
22 lines
635 B
Bash
Executable File
22 lines
635 B
Bash
Executable File
#!/bin/bash
|
|
set -ex
|
|
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
|
|
|
tmp_path="/tmp/authorized_keys"
|
|
dest_path="/home/ssh/.ssh/authorized_keys"
|
|
echo "# This file is autoly generated. Changes here will not work." > "$tmp_path"
|
|
|
|
for file in $(find "$THIS_DIR/../authorized_keys" -type f); do
|
|
(echo "# key file: ${file#*authorized_keys/}";cat "$file"; echo) >> "$tmp_path"
|
|
done
|
|
|
|
if [[ ! -d "/home/ssh/.ssh" ]]; then
|
|
mkdir -p "/home/ssh/.ssh"
|
|
chown ssh:ssh "/home/ssh/.ssh"
|
|
chmod 700 "/home/ssh/.ssh"
|
|
fi
|
|
cat "$tmp_path" > "$dest_path"
|
|
rm "$tmp_path"
|
|
chown ssh:ssh "$dest_path"
|
|
chmod 600 "$dest_path"
|