Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st. We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here. Need help or have questions? Drop us a line at [email protected]
Trying to use sudo to run commands(as root) in a cluster gives error
"
Stderr: Pseudo-terminal will not be allocated because stdin is not a terminal.
sudo: sorry, you must have a tty to run sudo"
This is a common situation where you are login as some other user in a terminal and then sudo to root to perform the task.
And you can only ssh from the user you logged in and not from root.
Solution:
Note: You have to install pssh if it is not already installed. in your cluster.
Keep all host names in a file say all_hosts
This kind of execution will fail:
pssh -i -h all_hosts "sudo whoami;hostname -f"
Will fail to execute and give error:
Stderr: sudo: sorry, you must have a tty to run sudo
OR
pssh -i -h all_hosts -x "-t" "sudo whoami;hostname -f"
Will fail to execute and give error:
Stderr: Pseudo-terminal will not be allocated because stdin is not a terminal. sudo: sorry, you must have a tty to run sudo