/etc/securetty 記錄了 root 可以安全登入的終端名稱,也能用來限制 telnet 之類的登入來源。
把檔案內容精簡到只剩兩行:
[root@localhost ~]# cat /etc/securetty
tty1
tty2
把 pts 裝置也加進來:
[root@localhost ~]# cat /etc/securetty
tty1
tty2
pts/1
pts/2
把檔案刪除或改名即可:
[root@localhost ~]# mv /etc/securetty /etc/securetty.bak
補充兩點:一是 securetty 主要約束的是 login 這類傳統登入流程,若你的環境走 SSH,還需要另外在 /etc/ssh/sshd_config 用 PermitRootLogin 與 AllowUsers 等設定搭配;二是保留 tty 條目時,實際存在的虛擬終端數量要與清單相符,否則可能把自己鎖在門外,改動前先留一份備份會更安心。