Add an entry to the sudoers file via ssh

I have a user called ‘jose’ in a remote server and this user has full sudo access, but we were not provided with the root password of this remote server since the ‘jose’ user has the full sudo access. I need to add an entry to the /etc/sudoers file in the remote server by running a script/command in my local machine.

Command used: ssh jose@ ‘sudo echo “ashira ALL=(ALL) NOPASSWD: /bin/su - a” >> /etc/sudoers’

I get the error: bash: /etc/sudoers: Permission denied

Also tried the command: ssh jose@ sudo -i ‘sudo echo “ashira ALL=(ALL) NOPASSWD: /bin/su - a” >> /etc/sudoers’

But same error is shown.

Can someone help me how to add an entry to the sudoers file by connecting to the remote server with the user ‘jose’ ?

P.S: Finally I added this entry by logging into the remote server manually. But there are hundreds of servers I need to add this record. So Please help me on what command should I execute to do this task.

Are you sure user named jose allowed to run any commands? It seems jose is not allowed to edit the /etc/sudoers file. Can you check permission for the jose user in /etc/sudoers file? Also let us know your OS name and version.

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki