Help ssh sudo - CentOS6

Mikmikmikmik

New Member
Joined
Nov 23, 2018
Messages
9
Reaction score
1
Credits
72
Hi,
Please help, sudo thinks the password file is v-users.

ssh -t -l myname server2 "cd /etc/mail; sudo -S /usr/sbin/hashmap v-users < v-users < ~/mypw.txt"
Ssh keys already set up for mynane.
Cat'ing the pw.txt and then pipe the sudo doesn't work either
I have tried all sorts of quoting but I just cannot get this to work.
I want the sudo entry to have a password to execute it so cannot use NOPASSWD: in the sudoers line.

Thanks.
 
Last edited:


G'day @Mikmikmikmik and welcome to linux.org :)

Seriously, though - do you think it might help to tell us a little bit more?

Like what Linux Distro you are on?

Is it your computer, and what are you trying to do?

I have only heard of "v-users" not exactly the same, but in context with Mac or Docker.

You will have to explain a whole lot more. I note that you have given us ssh references, and hope someone with more experience than I can recognise it, but the more info you give us, the better.

Cheers :)

Chris Turner
wizardfromoz
 
Does it matter what the command or redirection of stdin is for the command?
Its the fact that sudo thinks the first redirection for the command is the redirection for the sudo password.
You could do this if /bin/cat was in sudoers for the user:
ssh -t myname@server2 "sudo -S /bin/cat ~/onelinertextfile.txt < ~/myPW.txt"
Where ~/onelinertextfile & ~/myPW.txt is already saved in users home dir In server 2.
That works but this doesn't
ssh -t myname@server2 "sudo -S /bin/cat < ~/onelinertextfile < ~/myPW.txt" as sudo think ~/onelinertextfile is the redirected password.

I have ended up adding the command line I needed into a script, allowed the user to execute the script and the commands in the script within sudoers, and called the script in the sudo -S line. Unfortunately this means yet another file to modify on all remote servers. I suppose I could use Ansible, but am not allowed to. I'll just have to copy the file down to each remote box from the management box each time I want to execute it.

I may have got the -l option wrong in first post, cos i use pscp too from windows.
The OS is Centos6

Thanks.
 
Last edited:
G'day @Mikmikmikmik - I have modified your Thread Title to include CentOS6 so that it draws attention from the appropriate Members, I hope.

Good luck :)

Wizard
 
Hey there Mik - I'm trying to figure out what you're trying to do here.. catting the myPW.txt file into the onelinertextfile file? The issue you're running into though is passing the password for sudo? Or you're having another issue?

Is this a one time thing or are you running this on multiple servers with different content in each?
 

Staff online

Members online


Top