Skip to content

Commit

Permalink
treehouses ssh refactor (fixes #1578) (#1579)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <dogi@users.noreply.github.com>
  • Loading branch information
sarahrams and dogi authored Jul 3, 2020
1 parent 82f79ea commit c968584
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
36 changes: 21 additions & 15 deletions modules/ssh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@ function ssh {
checkroot
checkargn $# 1
status=$1
if [ "$status" = "on" ]; then
enable_service ssh
start_service ssh
echo "Success: the ssh service has been started and enabled when the system boots"
elif [ "$status" = "off" ]; then
disable_service ssh
stop_service ssh
echo "Success: the ssh service has been stopped and disabled when the system boots."
elif [ "$status" = "fingerprint" ]; then
ssh-keygen -l -E sha256 -f /etc/ssh/ssh_host_ecdsa_key.pub | cut -c5-54
elif [ "$status" = "" ]; then
last | grep -E "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
else
echo "Error: only '', 'on', 'off', or 'fingerprint' options are supported"
fi
case $status in
"on")
enable_service ssh
start_service ssh
echo "Success: the ssh service has been started and enabled when the system boots"
;;
"off")
disable_service ssh
stop_service ssh
echo "Success: the ssh service has been stopped and disabled when the system boots."
;;
"fingerprint")
ssh-keygen -l -E sha256 -f /etc/ssh/ssh_host_ecdsa_key.pub | cut -c5-54
;;
"")
last | grep -E "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
;;
*)
echo "Error: only '', 'on', 'off', or 'fingerprint' options are supported"
;;
esac
}

function ssh_help {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@treehouses/cli",
"version": "1.22.46",
"version": "1.22.47",
"remote": "2346",
"description": "Thin command-line interface for Raspberry Pi low level configuration.",
"main": "cli.sh",
Expand Down

0 comments on commit c968584

Please sign in to comment.