Why is `sudoedit` safer than `sudo vim /etc/file`?
IntermediateProductionSSH & Access Hardening
Answer
sudo vim runs the editor as root, and from vim you can run :!bash to get a root shell, defeating a narrowly scoped sudo rule. sudoedit /etc/nginx/nginx.conf copies the file to a temp file, runs your editor as you, then copies it back as root. Grant it in sudoers with %web sudoedit /etc/nginx/*.conf.
More on SSH & Access Hardening
What are the first sshd_config changes you make on a new production server?BeginnerWhy use a drop-in file in /etc/ssh/sshd_config.d/ instead of editing sshd_config?IntermediateWhy disable SSH password authentication entirely?BeginnerShould you change the SSH port from 22?IntermediateWhat are SSH certificates and why do large fleets use them?AdvancedHow do you restrict what a specific SSH key can do?Advanced