-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |