# Linux System Optimization
# OpenSSH
grep -E 'GSSAPIAuthentication|UseDNS' /etc/ssh/sshd_config | |
# Remove existing GSSAPIAuthentication and UseDNS lines to prevent duplicates | |
sed -i '/^GSSAPIAuthentication/d' /etc/ssh/sshd_config | |
sed -i '/^UseDNS/d' /etc/ssh/sshd_config | |
# Disable GSSAPIAuthentication and UseDNS | |
cat >>/etc/ssh/sshd_config <<EOF | |
GSSAPIAuthentication no | |
UseDNS no | |
EOF | |
systemctl restart sshd.service |
# History Command
Enable timestamp in history command.
~]# mkdir /var/log/history.d
~]# touch /var/log/history.d/history
~]# chmod 666 /var/log/history.d/history
~]# cat > /etc/profile.d/history.sh << "EOF"
shopt -s histappend
HISTTIMEFORMAT='%F %T '
HISTSIZE="5000"
HISTFILESIZE=5000
PROMPT_COMMAND='(umask 000; msg=$(history 1 | { read x y; echo $y; }); echo [$(who am i | awk "{print \$(NF-2),\$(NF-1),\$NF}")] [$(whoami)@`pwd`]" $msg" >>/var/log/history.d/history)'
export HISTTIMEFORMAT HISTSIZE HISTFILESIZE PROMPT_COMMAND
EOF