Skip to content

Commit

Permalink
feat(api): add settings option to reset ssh authorized keys (#13614)
Browse files Browse the repository at this point in the history
  • Loading branch information
vegano1 authored Sep 21, 2023
1 parent 9d3b69b commit 1ac718e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions api/src/opentrons/config/reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@


DATA_BOOT_D = Path("/data/boot.d")
AUTHORIZED_KEYS = Path(os.path.expanduser("~/.ssh/authorized_keys"))

log = logging.getLogger(__name__)

Expand All @@ -39,6 +40,7 @@ class ResetOptionId(str, Enum):
runs_history = "runsHistory"
on_device_display = "onDeviceDisplay"
module_calibration = "moduleCalibration"
authorized_keys = "authorizedKeys"


_OT_2_RESET_OPTIONS = [
Expand All @@ -55,6 +57,7 @@ class ResetOptionId(str, Enum):
ResetOptionId.runs_history,
ResetOptionId.on_device_display,
ResetOptionId.module_calibration,
ResetOptionId.authorized_keys,
]

_settings_reset_options = {
Expand Down Expand Up @@ -92,6 +95,9 @@ class ResetOptionId(str, Enum):
ResetOptionId.module_calibration: CommonResetOption(
name="Module Calibrations", description="Clear module offset calibrations"
),
ResetOptionId.authorized_keys: CommonResetOption(
name="SSH Authorized Keys", description="Clear the ssh authorized keys"
),
}


Expand Down Expand Up @@ -132,6 +138,9 @@ def reset(options: Set[ResetOptionId]) -> None:
if ResetOptionId.module_calibration in options:
reset_module_calibration()

if ResetOptionId.authorized_keys in options:
reset_authorized_keys()


def reset_boot_scripts() -> None:
if IS_ROBOT:
Expand Down Expand Up @@ -170,3 +179,9 @@ def reset_module_calibration() -> None:
clear_module_offset_calibrations()
except ImportError:
log.warning("Tried to clear module offset calibrations on an OT-2")


def reset_authorized_keys() -> None:
if IS_ROBOT and os.path.exists(AUTHORIZED_KEYS):
with open(AUTHORIZED_KEYS, "w") as fh:
fh.write("")
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ stages:
- id: moduleCalibration
name: Module Calibrations
description: !re_search 'Clear module offset calibrations'
- id: authorizedKeys
name: SSH Authorized Keys
description: !re_search 'Clear the ssh authorized keys'

- name: POST Reset gripperOffsetCalibrations true on OT-3
request:
Expand Down

0 comments on commit 1ac718e

Please sign in to comment.