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