12

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.

aaron
  • 741
  • 3
  • 10
  • 19
  • I would also suggest looking into using sudo instead of "su -c" – wfaulk Oct 08 '09 at 21:32
  • 1
    as I specified "I cannot use sudo" – aaron Oct 09 '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 07 '16 at 18:53
  • @dannysauer Not all OS's have it. I am here trying to solve the same problem, except that I'm not on RedHat like OP. I'm on a unix variant with no sudo. I'm curious as to why OP cannot use it on RedHat, but I'm grateful anyway that the question has been asked. – Loduwijk Oct 22 '19 at 18:11
  • sudo builds on all of the UNIX variants I'm familiar with, but I'll agree that it's not installed (or configured) on all of them. I was really more curious why it wasn't configured there (I think - it's been a few years). :D – dannysauer Oct 24 '19 at 19:51

2 Answers2

14

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 : 10.20.30.40
- : root : ALL EXCEPT LOCAL

and make sure UsePAM isn't disabled in sshd_config

geocar
  • 2,307
  • 14
  • 10
0

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'

or

ssh remote-server "su -c dmidecode"
Massimo
  • 68,714
  • 56
  • 196
  • 319