mirror of
https://github.com/deajan/obackup.git
synced 2024-11-15 04:03:41 +01:00
Fixed authorized_keys cleanup after tests
This commit is contained in:
parent
8bc1237ef0
commit
6587123d11
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
## obackup basic tests suite 2019071101
|
## obackup basic tests suite 2019071901
|
||||||
|
|
||||||
# Supported environment variables
|
# Supported environment variables
|
||||||
|
|
||||||
@ -87,9 +87,9 @@ OBACKUP_MIN_VERSION=x
|
|||||||
OBACKUP_IS_STABLE=maybe
|
OBACKUP_IS_STABLE=maybe
|
||||||
|
|
||||||
function SetupSSH {
|
function SetupSSH {
|
||||||
echo -e 'y\n'| ssh-keygen -t rsa -b 2048 -N "" -f "${HOME}/.ssh/id_rsa_local"
|
echo -e 'y\n'| ssh-keygen -t rsa -b 2048 -N "" -f "${HOME}/.ssh/id_rsa_local_obackup_tests"
|
||||||
if ! grep "$(cat ${HOME}/.ssh/id_rsa_local.pub)" "${HOME}/.ssh/authorized_keys"; then
|
if ! grep "$(cat ${HOME}/.ssh/id_rsa_local_obackup_tests.pub)" "${HOME}/.ssh/authorized_keys"; then
|
||||||
echo "from=\"*\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty,command=\"/usr/local/bin/ssh_filter.sh SomeAlphaNumericToken9\" $(cat ${HOME}/.ssh/id_rsa_local.pub)" >> "${HOME}/.ssh/authorized_keys"
|
echo "from=\"*\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty,command=\"/usr/local/bin/ssh_filter.sh SomeAlphaNumericToken9\" $(cat ${HOME}/.ssh/id_rsa_local_obackup_tests.pub)" >> "${HOME}/.ssh/authorized_keys"
|
||||||
fi
|
fi
|
||||||
chmod 600 "${HOME}/.ssh/authorized_keys"
|
chmod 600 "${HOME}/.ssh/authorized_keys"
|
||||||
|
|
||||||
@ -104,13 +104,10 @@ function SetupSSH {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function RemoveSSH {
|
function RemoveSSH {
|
||||||
local pubkey
|
if [ -f "${HOME}/.ssh/id_rsa_local_obackup_tests" ]; then
|
||||||
|
echo "Restoring SSH authorized_keys file"
|
||||||
if [ -f "${HOME}/.ssh/id_rsa_local" ]; then
|
sed -i.bak "s|.*$(cat "${HOME}/.ssh/id_rsa_local_obackup_tests.pub")||g" "${HOME}/.ssh/authorized_keys"
|
||||||
|
rm -f "${HOME}/.ssh/{id_rsa_local_obackup_tests.pub,id_rsa_local_obackup_tests}"
|
||||||
pubkey=$(cat "${HOME}/.ssh/id_rsa_local.pub")
|
|
||||||
sed -i.bak "s|.*$pubkey.*||g" "${HOME}/.ssh/authorized_keys"
|
|
||||||
rm -f "${HOME}/.ssh/{id_rsa_local.pub,id_rsa_local}"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user