Installation customization
Initial interaction
Having a public key loaded on the client (through ssh-agent) but none configured as being acceptable on the server may result in the initial ssh login failing.
To prevent confusion about the type of authentication requested, temporarily clear the SSH_AUTH_SOCK environment variable for the first ssh-based login.
This can be done by prepending the clause SSH_AUTH_SOCK= (ending in a space character) before the ssh command within bash, as in...
SSH_AUTH_SOCK= ssh root@10.5.6.7
Against a newly installed server, this should result in a password prompt.
The commands in the sections below should be entered, pasted preferably, over the initial ssh connection.
Command pasteability
Issue the follow command to allow straight pasting of commands into the bash-over-ssh command prompt,
bind 'set enable-bracketed-paste off'
Before this setting takes effect (i.e. when the command itself is pasted), an addititional press on the Enter key is needed while the command is being highlighted in inverse video.
Make the setting permanent, applied to future shells as well, with this command:
echo 'set enable-bracketed-paste off' >>/etc/inputrc
History volatilization
Ensure that no commands are persisted into command line history files on disk.
The HISTIGNORE environment value prevents commands that start with a space character from even appearing into the volatile command line history. This behavior may be useful when commands are issues that contain sensitive information in literal form.
FILE=/etc/profile.d/history.sh
cat <<. >$FILE
#!/bin/bash
export HISTIGNORE=\ *
export HISTFILE=/dev/null
.
. $FILE
Training wheel removal
bash aliases are defined that cause ‘are you sure’-type prompts to appear whenever the supposedly all-powerfall root removes, copy-overwrites or move-overwrites disk content...
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
Clear out this nonsense with the following command:
sed --regexp-extended "s/^alias.+-i'$/#\0/" --in-place /root/.bashrc
Prompt improvement
Make the bash command prompt look more like SuSE (with full paths being shown, and highlight in red used to denote root shells.
cat <<'.' >/etc/profile.d/prompt.sh
#!/bin/bash
## Borrowed from OpenSuSE 11.2's /etc/bash.bashrc
if [ "$PS1" ]; then
_t=""
if test "$UID" -eq 0 ; then
_u="\h"
_p=" #"
else
_u="\u@\h"
_p=">"
if test \( "$TERM" = "xterm" -o "${TERM#screen}" != "$TERM" \) \
-a -z "$EMACS" -a -z "$MC_SID" -a -n "$DISPLAY"
then
_t="\$(ppwd \l)"
fi
if test -n "$restricted" ; then
_t=""
fi
fi
PS1="${_t}${_u}:\w${_p} "
if test "$UID" -eq 0 -a -t ; then
_bred="$(tput bold 2> /dev/null; tput setaf 1 2> /dev/null)"
_sgr0="$(tput sgr0 2> /dev/null)"
PS1="\[$_bred\]$PS1\[$_sgr0\]"
unset _bred _sgr0
fi
# export PS1
fi
.
SSH key deposition
Place the SSH public key for the root user in the /root/.ssh/authorized_keys file, potentially by entering...
cat >.ssh/authorized_keys
..., pasting the public in, and closing the input with Ctrl-D.
Firewall disabling
Disable the system-wide firewall service using
systemctl disable firewalld
IPv6 disabling
IPv6 had been disabled on the interface level during installation, but the SSH service still has an IPv6 listener – which turns up in the output of netstat runs.
Set the address family for sshd to inet, IPv4 only;
sed 's/^#\(AddressFamily \)any$/\1inet/' --in-place /etc/ssh/sshd_config
SElinux disabling
sed 's/^\(SELINUX=\).*$/\1disabled/' --in-place /etc/selinux/config
Boot-up tweaking
grubby --args='spectre_v2=off nopti' --update-kernel 0
grubby --args='consoleblank=0' --update-kernel 0
# https://www.techbrown.com/change-default-grub2-entries-timeout-centos-7/
sed 's/^\(GRUB_TIMEOUT=\).*/\12/' --in-place /etc/default/grub
grub2-mkconfig --output=/boot/grub2/grub.cfg
Repository configuration
mount -o ro /dev/cdrom /media
rm --force --verbose /etc/yum.repos.d/*.repo
cat <<'.' >/etc/yum.repos.d/rocky.repo
[baseos]
name=Rocky Linux $releasever - BaseOS
baseurl=file:///media/BaseOS/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9
[appstream]
name=Rocky Linux $releasever - AppStream
baseurl=file:///media/AppStream/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9
.
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9
dnf makecache
dnf --assumeyes install rng-tools