First of all my Linux knowledge is limited! I'm more a developer, who casually manages some servers :-)
So, I'm operating on a farm of RHEL5/6 (mixed) servers and here is what I want to do: I have a Java program on one master server, which runs commands on some remote machines. The Java program sends my commands to the OS correctly - local commands can be executed without problems. My problem is the execution of commands on the remote servers:
- I've got the SSH keys, which allows my master to simply obtain root privileges on the slaves
- My command works, if I trigger it directly via a terminal (e.g.
ssh root@192.168.1.1 "cd /opt/bla"
) - I've tried different approaches, with different results - none of them correct :)
Attempt #1
$ ssh root@192.168.1.1
Pseudo-terminal will not be allocated because stdin is not a terminal.
Host key verification failed.
So, being familiar with Google, I've read about tty which was supposed to solve the problem but only lead to:
Attempt #2
$ ssh -t -t root@192.168.1.1
tcgetattr: Invalid argument
The authenticity of host '192.168.1.1 (192.168.1.1)' can't be established.
RSA key fingerprint is <somehex>.
So my application got stuck at this point, weirdly after Ctrl+C'ing it I've seen the following text:
Are you sure you want to continue connecting (yes/no)? Killed by signal 2.
So I'm assuming that something was working, it just got stuck on the input.
However, I was unable to find anything conclusive about this error. One hint somewhere was to edit /etc/sudoers
and comment out (I know it's not recommend)
# Defaults requiretty
which didn't do anything, although I have no idea if I should change this setting on the master and/or the slave and if a reboot or some restart of a daemon is required.
My question now is: does this lead anywhere or are my attempts worthless? Or is there any better way to run remote commands on slaves triggered by a program on the master machine? Please keep in mind I won't recompile my kernel or do any complicated shenanigan, since I'm simply lacking the experience with Linux..
Help is highly appreciated!