fix: devcontainer utils.sh ssh copy improvements (#3372)

fix utils.sh - use HOME variable, permissions and logging

Signed-off-by: Dave Lee <dave@gray101.com>
This commit is contained in:
Dave 2024-08-24 18:42:05 -04:00 committed by GitHub
parent 75ef6ccf1e
commit 99b57b321b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -32,19 +32,22 @@ config_remote() {
}
# Setup special .ssh files
#
# Prints out lines of text to make things pretty
# Param 1: bash array, filenames relative to the customization directory that should be copied to ~/.ssh
setup_ssh() {
mkdir -p ~/.ssh
echo "starting ~/.ssh directory setup..."
mkdir -p "${HOME}.ssh"
chmod 0700 "${HOME}/.ssh"
echo "-----"
local files=("$@")
for file in "${files[@]}" ; do
local cfile="/devcontainer-customization/${file}"
local hfile="~/.ssh/${file}"
local hfile="${HOME}/.ssh/${file}"
if [ ! -f "${hfile}" ]; then
echo "copying ${file}"
echo "copying \"${file}\""
cp "${cfile}" "${hfile}"
chmod 600 "${hfile}"
fi
done
ls ~/.ssh
echo "~/.ssh directory setup complete!"
}