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