I am trying to check the BIOS version of a server over SSH, a command that requires root privileges:

ssh remote-server su -c dmidecode

but this of course fails with the error:

standard in must be a tty

How do I make this work? I cannot use sudo, and when I try to log in as root@remote-server, it won't accept the password I use for the 'su' command. I am using RedHat Enterprise Linux 4.

  • I would also suggest looking into using sudo instead of "su -c" – wfaulk Oct 8 '09 at 21:32
  • 1
    as I specified "I cannot use sudo" – aaron Oct 9 '09 at 13:13
  • I'd love for there to have been more information as to why "I cannot use sudo" was the case. – dannysauer Mar 7 '16 at 18:53

Use -t to force ssh to allocate a tty:

ssh -t -t remote-user su -c dmidecode

You might also consider allowing root to ssh directly. If you're using public key authentication, this may be more secure as you won't be passing a password around. If you decide to do this, consider blocking root logins from anywhere except your trusted IP addresses by putting the following in /etc/security/access.conf:

+ : root :

and make sure UsePAM isn't disabled in sshd_config

  • 2
    Any reason you included two -ts in your example? – wfaulk Oct 8 '09 at 21:31
  • 2
    According to the man page, multiple -t options "force tty allocation, even if ssh has no local tty" – Heath Oct 8 '09 at 21:46
  • This doesn't work for me on Fedora. It allows the script to prompt me for my password, but my password displays as plaintext, and when I press enter, it just hangs. – Cerin Jan 20 '11 at 17:20
  • @Chris that's a different problem. Try asking a new question. – geocar Mar 13 '11 at 1:14
  • @Heath thanks for the comment about the double -t, that works for me on Centos – Paul Sheldrake Sep 25 '15 at 3:20

Can't you just log in to the remote server as a standard user and then use sudo?

You could also try quoting the command to be executed by ssh, as in

ssh remote-server 'su -c dmidecode'


ssh remote-server "su -c dmidecode"
  • 3
    -1 because quoting the command isn't going to resolve his lack of a terminal. +1 for suggesting sudo. It's a wash. – wfaulk Oct 8 '09 at 21:34
  • as I specified "I cannot use sudo" – aaron Oct 8 '09 at 21:37

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.