blob: 8a0b12b41a94ac81d1f3a709c7591f6b384339fa [file] [log] [blame]
Richard Felkld59c5652018-02-08 13:14:05 +01001#!/bin/bash -xe
2# Auto login root on tty1
3sed 's|/sbin/agetty|/sbin/agetty --autologin root|g' /etc/systemd/system/getty.target.wants/getty@tty1.service > /etc/systemd/system/getty-autologin@.service
4systemctl daemon-reload
5systemctl disable getty@tty1.service
6systemctl enable getty-autologin@tty1.service
7
8# Libvirt serial console support
9cat << 'EOF' >> /etc/systemd/system/serial-getty@.service
10[Unit]
11Description=Getty on %I
12Documentation=man:agetty(8) man:systemd-getty-generator(8)
13Documentation=http://0pointer.de/blog/projects/serial-console.html
14After=systemd-user-sessions.service plymouth-quit-wait.service
15After=rc-local.service
16
17Before=getty.target
18IgnoreOnIsolate=yes
19
20ConditionPathExists=/dev/ttyS0
21
22[Service]
23ExecStart=-/sbin/agetty --autologin root -8 --noclear %I 115200 $TERM
24Type=idle
25Restart=always
26RestartSec=0
27UtmpIdentifier=%I
28TTYPath=/dev/%I
29TTYReset=yes
30TTYVHangup=yes
31TTYVTDisallocate=yes
32KillMode=process
33IgnoreSIGPIPE=no
34SendSIGHUP=yes
35
36Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=
37
38[Install]
39WantedBy=getty.target
40DefaultInstance=ttyS0
41EOF
42
43systemctl daemon-reload
44systemctl enable serial-getty@ttyS0.service
45
46# Disable password root login
47usermod -p '!' root
48
49# Disable SSH password authentication and permit root login
50sed -i 's|[#]*PasswordAuthentication yes|PasswordAuthentication no|g' /etc/ssh/sshd_config
51sed -i 's|[#]*PermitRootLogin no|PermitRootLogin yes|g' /etc/ssh/sshd_config