Ubuntu Pastebin

Paste from ogra at Tue, 29 Dec 2015 11:42:29 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#! /bin/sh
#
# do a basic snappy server setup with static IP, personalized admin user and the
# default ubuntu user disabled

set -e

# define all settings here
HOSTNAME="aleph2"
TIMEZONE="Europe/Berlin"
USER="ogra"
IP="192.168.2.68"
GW="192.168.2.2"
DNS="8.8.8.8"

### do not edit below this line ###
cat << EOF | sudo snappy config ubuntu-core -- - >/dev/null
config:
  ubuntu-core:
    timezone: $TIMEZONE
    hostname: $HOSTNAME
    network:
      interfaces:
      - name: eth0
        content: |
          auto eth0
          allow-hotplug eth0
          iface eth0 inet static
          address $IP
          netmask 255.255.255.0
          gateway $GW
          dns-nameservers $DNS
EOF

echo "ubuntu-core configuration changed to:"
snappy config ubuntu-core

# create user and add to sudoers
sudo adduser --gecos $USER $USER --disabled-password --extrausers >/dev/null 2>&1 || true
echo "$USER ALL=(ALL:ALL) ALL"|sudo tee -a /etc/sudoers.d/90-sudo-users >/dev/null

# set up ssh login if a key is in place
sudo mv /home/ubuntu/.ssh /home/$USER/ || true
sudo chown -R $USER.$USER /home/$USER/.ssh || true

# set a user password
echo "Set password for $USER:"
sudo passwd $USER

# lock down default "ubuntu" user
sudo passwd -l ubuntu
sudo sed -i 's/^ubuntu /#ubuntu /' /etc/sudoers.d/90-cloud-init-users

# notify the user
echo "the \"ubuntu\" user was locked down, please re-login as $USER now, sudo will not work anymore with this user!"
Download as text