Interview Prep/Linux/SSH & Access Hardening

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.

All Linux questions Roadmap: Linux

More on SSH & Access Hardening