You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.4 KiB
47 lines
1.4 KiB
#!/bin/bash
|
|
#
|
|
# sysinit.sh
|
|
#
|
|
# Prepares new (virtual) hosts for ssh/ansible/spice usage
|
|
#
|
|
# Copyright 2018 Jonathan Golder <jonathan@golderweb.de>
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
# MA 02110-1301, USA.
|
|
#
|
|
#
|
|
|
|
# Config
|
|
KEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIRXfUXKV+VrWSyaFFy1T3KDRV9m6QKuLbWqa6wjazKp jonathan@golderweb.de (GPG)"
|
|
AUTHKEYFILE="${HOME}/.ssh/authorized_keys"
|
|
|
|
# Install ssh-server
|
|
sudo apt-get update
|
|
sudo apt-get -y install openssh-server
|
|
|
|
# Configure public key
|
|
# Make sure user's ssh config dir exist
|
|
if [[ ! -d "${HOME}/.ssh" ]]; then
|
|
mkdir "${HOME}/.ssh"
|
|
fi
|
|
|
|
# Add key to authorized_keys file if not present
|
|
if [[ ! -f "$AUTHKEYFILE" ]] || ! grep -q "$KEY" "$AUTHKEYFILE"; then
|
|
echo "$KEY" >> "$AUTHKEYFILE"
|
|
fi
|
|
|
|
# Install spice-vdagent
|
|
sudo apt-get -y install spice-vdagent
|
|
|
|
|