Community Articles
Find and share helpful community-sourced technical articles
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.
Problem:

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 

The correct command should be run like this:

pssh -i -h all_hosts -x "-t -t" "sudo whoami;hostname -f"

And you can safely ignore this error: "Stderr: tcgetattr: Invalid argument"

Your command will run in the way you intent it and you will be able to manage your cluster from one terminal

Hope this helps.

Thanks

2,233 Views
Don't have an account?
Coming from Hortonworks? Activate your account here
Version history
Revision #:
1 of 1
Last update:
‎04-04-2017 05:20 PM
Updated by:
 
Contributors
Top Kudoed Authors