-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'andrew/collapse-duplicated-code' into 'master'
Chore(NODE-1340): Consolidate setup-ssh-account-keys After consolidation, SSH successful on HostOS and GuestOS! See merge request dfinity-lab/public/ic!19442
- Loading branch information
Showing
9 changed files
with
38 additions
and
60 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
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
23 changes: 0 additions & 23 deletions
23
ic-os/rootfs/ssh/setup-ssh-account-keys/guestos/setup-ssh-account-keys.sh
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
ic-os/rootfs/ssh/setup-ssh-account-keys/hostos/setup-ssh-account-keys.service
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
ic-os/rootfs/ssh/setup-ssh-account-keys/hostos/setup-ssh-account-keys.sh
This file was deleted.
Oops, something went wrong.
3 changes: 1 addition & 2 deletions
3
ic-os/rootfs/ssh/setup-ssh-account-keys/setup-ssh-account-keys.service
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
30 changes: 30 additions & 0 deletions
30
ic-os/rootfs/ssh/setup-ssh-account-keys/setup-ssh-account-keys.sh
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
copy_ssh_keys() { | ||
local SOURCE_FILE="$1" | ||
local DEST_FILE="$2" | ||
if [ -e "${SOURCE_FILE}" ]; then | ||
cp -L "${SOURCE_FILE}" "${DEST_FILE}" | ||
chmod 600 "${DEST_FILE}" | ||
fi | ||
} | ||
|
||
for ACCOUNT in backup readonly admin; do | ||
HOMEDIR=$(getent passwd "${ACCOUNT}" | cut -d: -f6) | ||
GROUP=$(id -ng "${ACCOUNT}") | ||
|
||
mkdir -p "${HOMEDIR}/.ssh" | ||
chmod 700 "${HOMEDIR}" "${HOMEDIR}/.ssh" | ||
|
||
GUESTOS_AUTHORIZED_SSH_KEYS="/boot/config/accounts_ssh_authorized_keys/${ACCOUNT}" | ||
HOSTOS_AUTHORIZED_SSH_KEYS="/boot/config/ssh_authorized_keys/${ACCOUNT}" | ||
AUTHORIZED_KEYS_FILE="${HOMEDIR}/.ssh/authorized_keys" | ||
|
||
copy_ssh_keys "${GUESTOS_AUTHORIZED_SSH_KEYS}" "${AUTHORIZED_KEYS_FILE}" | ||
copy_ssh_keys "${HOSTOS_AUTHORIZED_SSH_KEYS}" "${AUTHORIZED_KEYS_FILE}" | ||
|
||
chown -R "${ACCOUNT}:${GROUP}" "${HOMEDIR}" | ||
restorecon -r "${HOMEDIR}" | ||
done |