0

i am running a command from my server which would remotely ssh to by client machine as root and sudo as olcne user and run few commands for validation. I have added the olcne user in sudoer list. i am able to locally execute these commands without any issue through sudo but when executed remotely i am getting the below error

Apr 18 06:28:02 client sudo:   olcne : user NOT authorized on host ; TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/etc/olcne/scripts/olcne-firewall-check 2379 tcp
Apr 18 06:28:03 client sudo:   olcne : user NOT authorized on host ; TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/etc/olcne/scripts/olcne-image-exists container-registry.oracle.com/olcne/kube-scheduler:v1.14.8


sudoer file

root ALL=(ALL) NOPASSWD: ALL
olcne ALL=(ALL) NOPASSWD: ALL

## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d

cat /etc/sudoers.d/olcne
Cmnd_Alias  OLCNE_PRIVILEGE = \
            /etc/olcne/scripts/
olcne  ALL=(root:ANY)  NOPASSWD: OLCNE_PRIVILEGE

Running the command from the client is success.

[root@client var]# sudo su olcne -c "sudo /etc/olcne/scripts/olcne-firewall-check 8472 udp"
yes
0

Can you try the below command from your server.

If script are on source server:

ssh olcne@client 'bash -s' < /etc/olcne/scripts/olcne-firewall-check

If scripts are on destination server hit the below from source server:

ssh user@destinationserver su --session-command="/path/to/command1 arg1 arg2"

hope this helps.

  • Script resides on the client and remote execution is done on the client – user1115980 Apr 22 '20 at 4:41
  • Can you please post /etc/olcne/scripts/olcne-firewall-check this script & error msg you are getting while executing. – Santosh Garole Apr 22 '20 at 6:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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