-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: adds ssh mode switching; production, maintenance, status and fa… #6
Open
fnerdman
wants to merge
1
commit into
master
Choose a base branch
from
ssh-mode-switch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,11 @@ Because root and password login are disabled by default, the TDX machine can onl | |
The meta-searcher layer appends: | ||
- searcher-ssh-key package to meta-confidential-compute layer's cvm-initramfs.bb | ||
- a new dropbear configuration to meta layer's dropbear that disables password logins | ||
- production, maintenance, status and failsafe ssh users that trigger mode switching wrapper scripts when logged into | ||
|
||
The meta-searcher layer is assigned priority = 30 to override configurations in other layers (meta-confidential-compute = 20). | ||
|
||
The searcher-ssh-key package creates the .ssh directory and adds the searcher's SSH pubkey to the authorized_keys file to the princess user. | ||
The searcher-ssh-key package creates the .ssh directory and adds the searcher's SSH pubkey to the authorized_keys file to the searcher user. | ||
The shell script is configured to run at the last stage of the init process. | ||
|
||
Note: some local networking commands add a static IP to enable testing via qemu. | ||
|
@@ -32,4 +33,4 @@ runqemu cvm-image-azure wic nographic kvm ovmf qemuparams="-m 8G" | |
``` | ||
ssh-keygen -f "/home/ubuntu/.ssh/known_hosts" -R "192.168.7.2" | ||
ssh -i ~/.ssh/id_rsa_princess [email protected] | ||
``` | ||
``` |
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 |
---|---|---|
@@ -1 +1 @@ | ||
PACKAGE_INSTALL:append = " dropbear searcher-ssh-key ssh-pubkey-server su-restriction disk-encryption" | ||
PACKAGE_INSTALL:append = " dropbear searcher-ssh-key ssh-pubkey-server su-restriction disk-encryption production maintenance status failsafe" |
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,7 @@ | ||
SUMMARY = "Adds failsafe mode user and script" | ||
DESCRIPTION = "Creates the failsafe mode user and sets up SSH access with the provided SSH key, limit's the user to execute the failsafe.sh wrapper script" | ||
|
||
require ssh-mode-switch.inc | ||
|
||
SSH_USER_ID = "1103" | ||
RDEPENDS:${PN} += "curl" | ||
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,4 @@ | ||
#!/bin/sh | ||
|
||
echo "Curling failsafe..." | ||
curl http://go-bob-firewall:80/failsafe |
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,4 @@ | ||
#!/bin/sh | ||
|
||
echo "Curling go-bob-firewall maintenance..." | ||
curl http://go-bob-firewall:80/firewall/maintenance |
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,4 @@ | ||
#!/bin/sh | ||
|
||
echo "Curling go-bob-firewall production..." | ||
curl http://go-bob-firewall:80/firewall/production |
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,4 @@ | ||
#!/bin/sh | ||
|
||
echo "Curling go-bob-firewall status..." | ||
curl http://go-bob-firewall:80/firewall/status |
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,7 @@ | ||
SUMMARY = "Adds maintenance mode user and script" | ||
DESCRIPTION = "Creates the maintenance mode user and sets up SSH access with the provided SSH key, limit's the user to execute the maintenance.sh wrapper script" | ||
|
||
require ssh-mode-switch.inc | ||
|
||
SSH_USER_ID = "1101" | ||
RDEPENDS:${PN} += "curl" |
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,7 @@ | ||
SUMMARY = "Adds production mode user and script" | ||
DESCRIPTION = "Creates the production mode user and sets up SSH access with the provided SSH key, limit's the user to execute the production-mode.sh wrapper script" | ||
|
||
require ssh-mode-switch.inc | ||
|
||
SSH_USER_ID = "1100" | ||
RDEPENDS:${PN} += "curl" |
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,65 @@ | ||
# Generic SSH user setup include file | ||
# Required variables: | ||
# - SSH_USER: Username to create | ||
# - SSH_USER_ID: Numeric user ID | ||
# - SSH_USER_KEY: SSH public key for the user | ||
# Optional variables: | ||
# - SSH_USER_SHELL: Shell for the user (defaults to /bin/sh) | ||
# - SSH_USER_HOME: Home directory (defaults to /home/${SSH_USER}) | ||
|
||
LICENSE = "MIT" | ||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" | ||
|
||
inherit useradd | ||
|
||
SRC_URI = "file://${BPN}.sh" | ||
|
||
# Set defaults if not defined | ||
SSH_USER ?= "${PN}" | ||
SSH_USER_KEY ?= "${SEARCHER_SSH_KEY}" | ||
SSH_USER_SHELL ?= "/bin/${PN}" | ||
SSH_USER_HOME ?= "/home/${SSH_USER}" | ||
|
||
USERADD_PACKAGES = "${PN}" | ||
USERADD_PARAM:${PN} = "-m -d ${SSH_USER_HOME} -s ${SSH_USER_SHELL} -u ${SSH_USER_ID} ${SSH_USER}" | ||
|
||
python () { | ||
# Check if SSH_USER_KEY is set in the environment or in local.conf | ||
ssh_key = d.getVar('SSH_USER_KEY') | ||
|
||
if ssh_key is None: | ||
# If not set, check the original environment | ||
origenv = d.getVar("BB_ORIGENV", False) | ||
if origenv: | ||
ssh_key = origenv.getVar('SSH_USER_KEY') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we use the already existing env var SEARCHER_SSH_KEY instead of introducing a new one? |
||
|
||
if ssh_key: | ||
# If SSH_USER_KEY is set, keep its value | ||
d.setVar('SSH_USER_KEY', ssh_key) | ||
else: | ||
# If SSH_USER_KEY is not set, raise an error | ||
bb.fatal("SSH_USER_KEY must be set. Please provide an SSH public key.") | ||
} | ||
|
||
do_install () { | ||
install -d ${D}${SSH_USER_HOME}/.ssh | ||
echo "${SSH_USER_KEY}" > ${D}${SSH_USER_HOME}/.ssh/authorized_keys | ||
chmod 700 ${D}${SSH_USER_HOME}/.ssh | ||
chmod 600 ${D}${SSH_USER_HOME}/.ssh/authorized_keys | ||
chown -R ${SSH_USER_ID}:${SSH_USER_ID} ${D}${SSH_USER_HOME} | ||
|
||
# Set up .profile to source /etc/profile | ||
echo '. /etc/profile' > ${D}${SSH_USER_HOME}/.profile | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need to source profile |
||
chmod 644 ${D}${SSH_USER_HOME}/.profile | ||
chown ${SSH_USER_ID}:${SSH_USER_ID} ${D}${SSH_USER_HOME}/.profile | ||
|
||
# set up wrapper script as user shell | ||
install -d ${D}/bin | ||
install -m 0555 ${WORKDIR}/${BPN}.sh ${D}${SSH_USER_SHELL} | ||
} | ||
|
||
FILES:${PN} = "${SSH_USER_HOME} \ | ||
${SSH_USER_HOME}/.ssh \ | ||
${SSH_USER_HOME}/.ssh/authorized_keys \ | ||
${SSH_USER_HOME}/.profile \ | ||
${SSH_USER_SHELL}" |
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,7 @@ | ||
SUMMARY = "Adds status mode user and script" | ||
DESCRIPTION = "Creates the status mode user and sets up SSH access with the provided SSH key, limit's the user to execute the status.sh wrapper script" | ||
|
||
require ssh-mode-switch.inc | ||
|
||
SSH_USER_ID = "1102" | ||
RDEPENDS:${PN} += "curl" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need the failsafe to be also exposed and be callable by its own SSH USER?
I thought the fail safe triggers in case the production or maintenance scripts fail.