Skip to content

Commit

Permalink
Merge pull request #46 from kjetilmjos/dev
Browse files Browse the repository at this point in the history
august release
  • Loading branch information
kjetilmjos authored Aug 18, 2023
2 parents eb97f1b + 348d1b8 commit 87de952
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 33 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2023.8.0
- Improved ssh key generation to make sure a new one is generated if a new username is inputted.

## 2023.7.4
- Changed default backup time to 1 week interval

Expand Down
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "m-connect"
description: "Wireguard client for reverse proxy in cloud setup"
version: "2023.7.4"
version: "2023.8.0"
slug: "m_connect"
init: false
url: https://github.com/kjetilmjos/m-connect
Expand Down
57 changes: 25 additions & 32 deletions rootfs/etc/s6-overlay/scripts/startupbackupscript
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,40 @@
# Creates the backup configuration
# ==============================================================================
declare username
#backup_enable=true

# Get config input from addon UI
#if bashio::config.has_value "server.enable_backup"; then
# backup_enable=$(bashio::config "server.enable_backup")
#fi
#bashio::exit.die_if_false $backup_enable "Backup is disabled. Backup startup script will stop"
#if [[ $backup_enable = false ]]; then
# bashio::log.warning
# bashio::log.warning "Backup is disabled. Backup startup script will exit"
# bashio::log.warning
# bashio::exit.ok
#fi

if bashio::config.has_value "server.username"; then
username=$(bashio::config "server.username")
fi

# If private key is already existing, don't create a new one
#if bashio::fs.file_exists "/backup_cred/${username}.pub"; then
# bashio::log.info "An existing ssh key was found. A new one will not be generated"
# bashio::exit.ok
#fi

# Wireguard configuration directory
if bashio::fs.directory_exists '/data/backup_cred'; then
bashio::log.info "An existing ssh key was found. A new one will not be generated"
bashio::log.info "An existing directory was found. A new one will not be generated"
if bashio::fs.file_exists "/data/backup_cred/$username.pub"; then
bashio::log.info "An existing ssh identity was found. A new one will not be generated"
pubkey=$(cat "/data/backup_cred/$username.pub")
bashio::log.info "The ssh public key is: $pubkey"
bashio::exit.ok
else
ssh-keygen -t ed25519 -C "$username" -f /data/backup_cred/$username -P ""
eval "$(ssh-agent -s)"
ssh-add /data/backup_cred/$username

#Print the SSH public key
pubkey=$(cat "/data/backup_cred/$username.pub")
bashio::log.info "The ssh public key is: $pubkey"
bashio::exit.ok
fi
fi
else
mkdir -p /data/backup_cred
# Creating required folder for ssh-copy-id
#mkdir -p ~/.ssh
ssh-keygen -t ed25519 -C "$username" -f /data/backup_cred/$username -P ""
# Use command permitted i authorized key fila: https://www.ssh.com/academy/ssh/authorized-keys-file
eval "$(ssh-agent -s)"
ssh-add /data/backup_cred/$username

mkdir -p /data/backup_cred
# Creating required folder for ssh-copy-id
mkdir -p ~/.ssh
ssh-keygen -t ed25519 -C "$username" -f /data/backup_cred/$username -P ""
# Bruk command permitted i authorized key fila: https://www.ssh.com/academy/ssh/authorized-keys-file
eval "$(ssh-agent -s)"
ssh-add /data/backup_cred/$username
#sshpass -p "$password" ssh-copy-id -o "StrictHostKeyChecking no" -i /data/backup_cred/$username $username@$host
#Print the SSH public key
pubkey=$(cat "/data/backup_cred/$username.pub")
bashio::log.info "The ssh public key is: $pubkey"
fi

#Print the SSH public key
pubkey=$(cat "/data/backup_cred/$username.pub")
bashio::log.info "The ssh public key is: $pubkey"

0 comments on commit 87de952

Please sign in to comment.