2

I have a problem running a ssh from crontab against a Fujitsu DX200 storage appliance.

When running the command from terminal everything works okay connecting using RSA keys, but when I embed the command in a script and run it from cron it fails with "Pseudo-terminal will not be allocated because stdin is not a terminal."

The command is ssh user@dx200 "show performance -type host-io"

According to many articles on the net, adding a number of -t as an argument to ssh it should force allocating PTY. On RedHat, where the script was developed, it works by adding -t -t -t (or -ttt) but that's not the case when running on Ubuntu.

Using ssh -T (Disable pseudo-tty allocation) makes the login to dx200 fail with "FUJITSU Storage ETERNUS login is required..." - that is, not logging in whit RSA key.

Other solutions from the net, using variants of ssh ... /bin/bash <<EOF ... is not possible because we cant launch a shell on the storage appliance.

Any ideas on how to circumvent this issue?

Melebius
  • 11,121
  • 8
  • 50
  • 77
Soren A
  • 6,442
  • 2
  • 17
  • 33
  • It looks like that I solved the problem. An extra `-t` on the ssh command and there are connection through. Now there are four. What are the mechanism that decides how many `-t` are necessary ? – Soren A May 03 '18 at 13:44
  • What about the option `-n`? I'm thinking whether your question is possible duplicate of [While loop only processes the first entry of ssh command](https://askubuntu.com/q/979442/566421) (see also [this](https://askubuntu.com/q/986179/566421))? – pa4080 May 04 '18 at 09:52
  • 1
    @pa4080, I tried that too, it didn't work either. As I remember, it broke the login. This might be because the sshd or the shell in the DX200 is a little rudimentary compared to a linux setup. – Soren A May 04 '18 at 10:38

1 Answers1

1

Answering my own question ...

Adding an extra -t argument to ssh solved the problem.

The command now looks like ssh -t -t -t -t user@dx200 ...... ( -tttt should do the same).

The man page on ssh say's this about -t:

 -t      Force pseudo-tty allocation.  This can be used to execute arbi-
         trary screen-based programs on a remote machine, which can be
         very useful, e.g. when implementing menu services.  Multiple -t
         options force tty allocation, even if ssh has no local tty.

But nothing about how many 'Multiple' is, or what in the ssh code that governs the number of -t options required.

Soren A
  • 6,442
  • 2
  • 17
  • 33