mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-19 06:04:21 +01:00
Merge pull request #12 from home-assistant/build
Update Readme / Add ssh server addon
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
# hassio-addons
|
# hassio-addons
|
||||||
Docker addons for HassIO
|
Docker addons for HassIO
|
||||||
|
|
||||||
[HassIO](https://github.com/pvizeli/hassio)
|
All PRs need to be `build` branch!
|
||||||
[HassIO-Build](https://github.com/pvizeli/hassio-build)
|
|
||||||
|
[HassIO](https://github.com/pvizeli/hassio) | [HassIO-Build](https://github.com/pvizeli/hassio-build)
|
||||||
|
|
||||||
## Addon folder
|
## Addon folder
|
||||||
|
|
||||||
@@ -55,4 +56,4 @@ If you want to set a value to requered and need to be set from user before it st
|
|||||||
Default you can use `fullchain.pem` and `privkey.pem` from `/ssl` for you stuff. Your SSL addon should also create default this files.
|
Default you can use `fullchain.pem` and `privkey.pem` from `/ssl` for you stuff. Your SSL addon should also create default this files.
|
||||||
|
|
||||||
## Addon need to known
|
## Addon need to known
|
||||||
`/data` is a volume with a persistant store. `/data/options.json` have the user config inside. You can use `jq` inside shell script to parse this data. A other nice tool for write plugin is [Supervisor](http://supervisord.org/).
|
`/data` is a volume with a persistant store. `/data/options.json` have the user config inside. You can use `jq` inside shell script to parse this data.
|
||||||
|
|||||||
@@ -3,10 +3,7 @@ MQTT broker for HomeAssistant and HassIO addons.
|
|||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
- `plain`:
|
- `plain`: For connection with 1883 (without SSL/TLS)
|
||||||
- `ssl`:
|
- `ssl`: For connection with 8883 (with SSL/TLS)
|
||||||
- `ssl`:
|
- `anonymous`: For anonymous authentication
|
||||||
- `anonymous`:
|
- `logins`: A list of login data `{"username": "", "password": ""}`
|
||||||
- `logins`:
|
|
||||||
- `certfile`:
|
|
||||||
- `keyfile`:
|
|
||||||
|
|||||||
15
ssh/Dockerfile
Normal file
15
ssh/Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
FROM %%BASE_IMAGE%%
|
||||||
|
|
||||||
|
# Add version
|
||||||
|
ENV VERSION %%VERSION%%
|
||||||
|
ENV LANG C.UTF-8
|
||||||
|
|
||||||
|
# Setup base
|
||||||
|
RUN apk add --no-cache jq openssh vim
|
||||||
|
|
||||||
|
# Copy data
|
||||||
|
COPY run.sh /
|
||||||
|
|
||||||
|
RUN chmod a+x /run.sh
|
||||||
|
|
||||||
|
CMD [ "/run.sh" ]
|
||||||
9
ssh/README.md
Normal file
9
ssh/README.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# SSH server
|
||||||
|
Provide a openssh server. You can access to:
|
||||||
|
- /config: HomeAssistant config
|
||||||
|
- /addons: Custom addon folder
|
||||||
|
- /ssl: Store ssh key files for HassIO
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
- `authorized_keys`: A array that ever element is a authorized key
|
||||||
18
ssh/config.json
Normal file
18
ssh/config.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "SSH server",
|
||||||
|
"version": "0.1",
|
||||||
|
"slug": "ssh",
|
||||||
|
"description": "OpenSSH is the premier connectivity tool for remote login with the SSH protocol.",
|
||||||
|
"startup": "before",
|
||||||
|
"boot": "auto",
|
||||||
|
"ports": {
|
||||||
|
"22/tcp": 22
|
||||||
|
},
|
||||||
|
"map": ["config", "ssl", "addons"],
|
||||||
|
"options": {
|
||||||
|
"authorized_keys": [null]
|
||||||
|
},
|
||||||
|
"schema": {
|
||||||
|
"authorized_keys": ["str"]
|
||||||
|
}
|
||||||
|
}
|
||||||
29
ssh/run.sh
Normal file
29
ssh/run.sh
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
CONFIG_PATH=/data/options.json
|
||||||
|
KEYS_PATH=/data/host_keys
|
||||||
|
|
||||||
|
AUTHORIZED_KEYS=$(jq --raw-output ".authorized_keys[]" $CONFIG_PATH)
|
||||||
|
|
||||||
|
# Init defaults config
|
||||||
|
sed -i s/#PermitRootLogin.*/PermitRootLogin\ yes/ /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
# Generate authorized_keys file
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
for line in $AUTHORIZED_KEYS; do
|
||||||
|
echo "$line" >> ~/.ssh/authorized_keys
|
||||||
|
done
|
||||||
|
chmod 600 ~/.ssh/authorized_keys
|
||||||
|
|
||||||
|
# Generate host keys
|
||||||
|
if [ ! -d "$KEYS_PATH" ]; then
|
||||||
|
mkdir -p "$KEYS_PATH"
|
||||||
|
ssh-keygen -A
|
||||||
|
cp -fp /etc/ssh/ssh_host* "$KEYS_PATH/"
|
||||||
|
else
|
||||||
|
cp -fp "$KEYS_PATH/*" /etc/ssh/
|
||||||
|
fi
|
||||||
|
|
||||||
|
# start server
|
||||||
|
exec sshd -D -f /etc/sshd_config < /dev/null
|
||||||
Reference in New Issue
Block a user