Persistent SSH Key Example (#92)

This commit is contained in:
Jared Komoroski 2021-01-04 22:10:40 -07:00 committed by GitHub
parent f2810f184a
commit be71225ef7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -49,6 +49,7 @@
Examples:
* Start a DNS Container [10-dns.sh](../dns-common/on_boot.d/10-dns.sh)
* Start wpa_supplicant [on_boot.d/10-wpa_supplicant.sh](examples/udm-files/on_boot.d/10-wpa_supplicant.sh)
* Add a persistent ssh key for the root user [on_boot.d/15-add-root-ssh-key.sh](examples/udm-files/on_boot.d/15-add-root-ssh-key.sh)
## Version History

View File

@ -0,0 +1,10 @@
#!/bin/sh
MY_SSH_KEY="ADD PUBLIC SSH KEY HERE"
KEYS_FILE="/root/.ssh/authorized_keys"
# Places public key in ~/.ssh/authorized_keys if not present
if ! grep -Fxq "$MY_SSH_KEY" "$KEYS_FILE"; then
echo "$MY_SSH_KEY" >> "$KEYS_FILE"
fi