How to SSH Directly Into a sudo Shell Without Getting Stuck
How to SSH Directly Into a sudo Shell Without Getting Stuck When working with Linux servers, it's common to log in with an administrative user (not root ) and then elevate privileges with sudo . But sometimes we want to SSH directly into a root-like shell without typing sudo every time. At first glance, you might think something like this works: ssh admin@host "sudo -i" Unfortunately, it doesn’t behave as expected. Instead of dropping you into an interactive shell, the session hangs or immediately exits. Why? Let’s break it down. Why ssh admin@host "sudo -i" Fails By default, SSH does not allocate a pseudo-terminal (PTY) when executing a remote command. sudo -i (or sudo su - ) launches an interactive login shell. Without a PTY, sudo has nowhere to attach its interactive session. Result: you either get stuck waiting for input or the session terminates right away. If you enable debug output ( ssh -v ), you might see something like this...