poudenes
(Poudenes)
1
Hi All,
I want following:
SSH to a server with auth key. Then sudo su and give a password. Then a command.
ssh -i /config/ssh_keys/no_pass -o StrictHostKeyChecking=no [email protected] -p 1234
This part is working when I do this from command line of HAOS.
But the rest I don’t know. Can someone assist me?
Thanks
Spiro
2
Try something like this format with the " and ’
command_on: "ssh -i /config/ssh_keys/key1 -o 'StrictHostKeyChecking=no' [email protected] 'poweroff'"
poudenes
(Poudenes)
3
Disabled root for ssh. use a different user. When I’m in the SSH session I do sudo su with a password.
Spiro
5
"ssh -i /config/ssh_keys/no_pass -o StrictHostKeyChecking=no [email protected] -p 1234 sudo -S whatevercommand"
Just a suggestion to try this. Never tried other than using root.
poudenes
(Poudenes)
6
this will ask for password for user root
poudenes
(Poudenes)
7
What I did now is following:
command_line:
- switch:
name: "Backup Full manual"
unique_id: "154c03eb-abb8-4b86-941f-d6d3f0495c76"
command_on: 'ssh -i /config/ssh_keys/no_pass -o StrictHostKeyChecking=no [email protected] -p 1234 "sudo -S /usr/local/sbin/backup-full.sh"'
- switch:
name: "MVPS - Backup dB manual"
unique_id: "154c03eb-abb8-4b86-941f-d6d3f0495c76"
command_on: 'ssh -i /config/ssh_keys/no_pass -o StrictHostKeyChecking=no [email protected] -p 1234 "sudo -S /usr/local/sbin/backup-db.sh"'
On server to root user
visudo
add this line:
<user> ALL=(ALL) NOPASSWD: /usr/local/sbin/backup-full.sh,/usr/local/sbin/backup-db.sh
This gives the without root permissions the rights to execute only the lines behind the NOPASSWD.
This works.