Support to use SSH as webterminal only (#1117)

This commit is contained in:
Pascal Vizeli
2020-02-20 10:49:53 +01:00
committed by GitHub
parent 2911ba3c44
commit 2df8425e22
4 changed files with 21 additions and 9 deletions

View File

@@ -1,5 +1,7 @@
# Changelog
- Support to use only web terminal without SSH server
## 8.3
- Update Home Assistant CLI to 4.0.1

View File

@@ -1,6 +1,6 @@
# Home Assistant Add-on: SSH server
Allow logging in remotely to Home Assistant using SSH.
Allow logging in remotely to Home Assistant using SSH or just the web terminal with Ingress.
![Supports aarch64 Architecture][aarch64-shield] ![Supports amd64 Architecture][amd64-shield] ![Supports armhf Architecture][armhf-shield] ![Supports armv7 Architecture][armv7-shield] ![Supports i386 Architecture][i386-shield]
@@ -12,7 +12,7 @@ client. It also includes a command-line tool to access the Home Assistant API.
Try it out using:
```bash
hassio help
ha help
```
## Installation
@@ -25,6 +25,9 @@ Follow these steps to get the add-on installed on your system:
## How to use
You need enable the port for external access. You can just enter 22 as value or any other
value like you want. This recommend to add login credentials.
To use this add-on, you must have a private/public key to log in.
To generate them, follow the [instructions for Windows][keygen-windows]
and [these for other platforms][keygen]. It is possible to set a password for

View File

@@ -1,10 +1,11 @@
{
"name": "SSH server",
"version": "8.3",
"name": "Terminal & SSH",
"version": "8.4",
"slug": "ssh",
"description": "Allow logging in remotely to Home Assistant using SSH",
"url": "https://github.com/home-assistant/hassio-addons/tree/master/ssh",
"arch": ["armhf", "armv7", "aarch64", "amd64", "i386"],
"advanced": true,
"startup": "services",
"ingress": true,
"panel_icon": "mdi:console",
@@ -14,7 +15,7 @@
"hassio_role": "manager",
"auto_uart": true,
"ports": {
"22/tcp": 22
"22/tcp": null
},
"map": ["config:rw", "ssl:rw", "addons:rw", "share:rw", "backup:rw"],
"options": {

View File

@@ -6,6 +6,7 @@ KEYS_PATH=/data/host_keys
WAIT_PIDS=()
bashio::log.info "Initializing add-on for use..."
USE_SSHD=true
if bashio::config.has_value 'authorized_keys'; then
bashio::log.info "Setup authorized_keys"
@@ -30,8 +31,11 @@ elif bashio::config.has_value 'password'; then
sed -i s/#PasswordAuthentication.*/PasswordAuthentication\ yes/ /etc/ssh/sshd_config
sed -i s/#PermitEmptyPasswords.*/PermitEmptyPasswords\ no/ /etc/ssh/sshd_config
else
elif bashio::var.has_value "$(bashio::addon.port 22)"; then
bashio::exit.nok "You need to setup a login!"
else
USE_SSHD=false
bashio::log.info "Disable SSH remote access because of missing login credential!"
fi
# Generate host keys
@@ -93,9 +97,11 @@ function stop_addon() {
trap "stop_addon" SIGTERM SIGHUP
# Start SSH server
bashio::log.info "Starting SSH daemon..."
/usr/sbin/sshd -D -e < /dev/null &
WAIT_PIDS+=($!)
if bashio::var.true "${USE_SSHD}"; then
bashio::log.info "Starting SSH daemon..."
/usr/sbin/sshd -D -e < /dev/null &
WAIT_PIDS+=($!)
fi
# Start ttyd server
bashio::log.info "Starting Web Terminal..."