0

we have very strange problem when we configure and start the firewall on remote machine

when we run VIA ssh the following command ( from bash script ) ,

  • we have redhat 7 machine

    systemctl start firewalld.service

example from script:

ssh $USER@$IP systemctl enable firewalld.service
ssh $USER@$IP systemctl start firewalld.service

then we get message about timeout from command - systemctl start firewalld.service

but when we run the - systemctl start firewalld.service manual on machine

then we accessed to run it

so why VIA SSH we cant run the command but local we can run it ?

what are the differences here ?

shalom
  • 461
  • 13
  • 29

1 Answers1

0

I don't have a Redhat 7 machine at hand, so I can't show exact values. But:

When you log in, you usually get a rich environment for your convenience during interactive sessions. Depends on your setup, of course, because you can set any environment you want adding statements to /etc/profile, $HOME/.bashrc and in many more ways.

In contrast, when just issuing a remote command, you get a more minimum environment; some directories may not in your PATH environment variable e.g.

An easy way to see the different environments will be the following thwo sessions:

ssh $USER@$IP env

versus

ssh $USER@$IP
env
exit

You may start by comparing the PATH values and try running your command systemctl enable firewalld.service on the interactive shell, but after changing the PATH variable to the non-interactive variant of it.

If that doesn't give you a bingo yet, set the entire environment of your interactive session exactly as in the non-interactive version.

There's another difference for the ssh host command way: you don't get a tty; you see this issuing the command tty. Your interactive sessiong will answer something like /dev/pts/3, while ssh host tty will answer not a tty. I'm note aware of systemctl being dependent on a tty or even behave the slightes bit differently, but other commands it envokes may do so. You may require ssh to allocate a tty adding the -t switch like ssh -t $USER@$IP systemctl enable firewalld.service to see wether it makes a difference.

TomTomTom
  • 611
  • 3
  • 6