Skip to content

Commit

Permalink
add remote access switch
Browse files Browse the repository at this point in the history
This is backport of #3485,
which adds remote access switch to eve, blocking ssh and edge-view if
remote access is disabled.

Signed-off-by: Shahriyar Jalayeri <shahriyar@zededa.com>
  • Loading branch information
shjala authored and eriknordmark committed Oct 19, 2023
1 parent 0e978f0 commit 78e6d65
Show file tree
Hide file tree
Showing 15 changed files with 5,711 additions and 5,607 deletions.
1,702 changes: 857 additions & 845 deletions api/go/info/info.pb.go

Large diffs are not rendered by default.

500 changes: 250 additions & 250 deletions api/images/devconfig.dot

Large diffs are not rendered by default.

7,108 changes: 3,554 additions & 3,554 deletions api/images/devconfig.dot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified api/images/devconfig.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions api/proto/info/info.proto
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,9 @@ message ZInfoDevice {

// Capability indicating which new EdgeDevConfig fields which are supported
APICapability api_capability = 51;

// Reports the remote access status
bool remote_access_disabled = 52;
}

// Capabilities indicates features in the EdgeDevConfig where there is
Expand Down
231 changes: 119 additions & 112 deletions api/python/info/info_pb2.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ In general, EVE is trying to make sure that its controller always has the last w
* `wpa_supplicant.conf` - a legacy way of configuring EVE's WiFi
* `authorized_keys` - initial authorized SSH keys for accessing EVE's debug console
* `bootstrap-config.pb`- initial device configuration used only until device is onboarded (see below for details)
* `remote_access_disabled`- a file indicating remote access status, if it exist remote access (edge-view and ssh) is disabled. Please check [config document](SECURITY.md#disabling-remote-access) for more information.

The initial content of these configuration files is stored in the EVE's source tree under [config](../config) folder. From there, these configuration files are baked into the EVE installer images. For the read-write bootable disk installer image these files can further be tweaked by mounting the "EVE" partition and editing those files directly on the installer image. This gives you an ability to take the default installer image and tweak it for your needs without re-building EVE from scratch (obviously this is not an option for a read-only ISO installer image). A typical workflow is to take an installer image from the official EVE build, flash it onto a USB flash drive, insert that USB flash drive into your desktop and edit file on the partition called EVE.

Expand Down
4 changes: 4 additions & 0 deletions docs/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ Two ECOs communicating using the overlay will get an secure channel since LISP w

In addition, the LISP map server can provide ability to limit access to the mappings for certain EIDs based on the EID which is trying to look them up.

## Disabling Remote Access

EVE provides a mechanism to build an image with remote access disabled (edge-view and ssh), this can be done by configuring EVE when building an installer. Enabling remote access back requires access to the cloud controller to enable console keyboard access on the edge node, plus physical access to the edge node to issue `eve remote-access` command on the edge node. In addition changing remote access status from its initial value to anything else will result in change of PCR-14 value and subsequent failure in unsealing the vault key that needs to be handled using the cloud controller. Check [config document](CONFIG.md#eve-configuration) for more information.

## Details on keys and certificates

These details are specified in [KEYS-AND-CERTS](KEYS-AND-CERTS.md).
13 changes: 12 additions & 1 deletion pkg/debug/ssh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,15 @@ echo -1 > /proc/sys/kernel/perf_event_paranoid
KEYS=$(find /etc/ssh -name 'ssh_host_*_key')
[ -z "$KEYS" ] && ssh-keygen -A >/dev/null 2>/dev/null

exec /usr/sbin/sshd -D -e

if [ -f "/config/remote_access_disabled" ]; then
# this is picked up by newlogd
echo "Remote access disabled, ssh server not started" > /dev/kmsg
while true; do
# sleep for INT_MAX, keep the container running
sleep inf
done
else
exec /usr/sbin/sshd -D -e
fi

22 changes: 22 additions & 0 deletions pkg/dom0-ztools/rootfs/bin/eve
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Welcome to EVE!
persist attach <disk>
config mount <mountpoint>
config unmount
remote-access on|off
firewall drop
verbose on|off
version
Expand Down Expand Up @@ -151,6 +152,27 @@ __EOT__
;;
esac
;;
remote-access)
CONFIGDIR_RW="/tmp/config_rw"
mkdir $CONFIGDIR_RW
if eval "$(mount_partlabel "CONFIG" $CONFIGDIR_RW)"; then
case "$2" in
on) rm -f $CONFIGDIR_RW/remote_access_disabled
eval "$(unmount_partlabel "CONFIG")" && rm -rf $CONFIGDIR_RW
echo "Remote access enabled. Please reboot to apply changes."
;;
off) touch $CONFIGDIR_RW/remote_access_disabled
eval "$(unmount_partlabel "CONFIG")" && rm -rf $CONFIGDIR_RW
echo "Remote access disabled. Please reboot to apply changes."
;;
*) eval "$(unmount_partlabel "CONFIG")" && rm -rf $CONFIGDIR_RW
help
;;
esac
else
echo "Failed to set the remote access configuration!"
fi
;;
version)
v=$(cat /run/eve-release)
echo "$v"
Expand Down
6 changes: 6 additions & 0 deletions pkg/pillar/cmd/zedagent/parseedgeview.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@ import (
"github.com/google/go-cmp/cmp"
zconfig "github.com/lf-edge/eve/api/go/config"
"github.com/lf-edge/eve/pkg/pillar/types"
"github.com/lf-edge/eve/pkg/pillar/utils"
)

// edge-view specific parser/utility routines

func parseEvConfig(ctx *getconfigContext, config *zconfig.EdgeDevConfig) {
if utils.RemoteAccessDisabled() {
log.Noticef("Remote access to edgeview is disabled")
removeEvFiles()
return
}

log.Tracef("Started parsing edge-view config")
zcfgEv := config.GetEdgeview()
Expand Down
3 changes: 3 additions & 0 deletions pkg/pillar/cmd/zedagent/reportinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ func PublishDeviceInfoToZedCloud(ctx *zedagentContext) {

ReportDeviceInfo := new(info.ZInfoDevice)

// Get the remote access status
ReportDeviceInfo.RemoteAccessDisabled = utils.RemoteAccessDisabled()

var uname unix.Utsname
err := unix.Uname(&uname)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/pillar/types/locationconsts.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const (
APIV1FileName = IdentityDirname + "/Force-API-V1"
// BootstrapConfFileName - file to store initial device configuration for bootstrapping
BootstrapConfFileName = IdentityDirname + "/bootstrap-config.pb"
// RemoteAccessFlagFileName -- file to check for remote access configuration
RemoteAccessFlagFileName = IdentityDirname + "/remote_access_disabled"
// BootstrapShaFileName - file to store SHA hash of an already ingested bootstrap config
BootstrapShaFileName = IngestedDirname + "/bootstrap-config.sha"

Expand Down
21 changes: 21 additions & 0 deletions pkg/pillar/utils/access.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2017-2023 Zededa, Inc.
// SPDX-License-Identifier: Apache-2.0

package utils

import (
"os"

"github.com/lf-edge/eve/pkg/pillar/types"
)

// RemoteAccessDisabled checks if remote access is enabled/disabled
// by checking if the file /config/remote_access_disabled exists or not.
func RemoteAccessDisabled() bool {
if _, err := os.Stat(types.RemoteAccessFlagFileName); err == nil {
// file exists, remote access is disabled
return true
} else {
return false
}
}
Loading

0 comments on commit 78e6d65

Please sign in to comment.