0

I'm trying to set up a deployment pipeline that involves invoking systemctl to start and stop services. I have a shell script on the server that invokes systemctl and my build server will be invoking the shell script via remote ssh.

But systemctl requires sudo rights and therefore prompts for a password. Is there a way to invoke systemctl via remote ssh that doesn't require user interaction?

KevinS
  • 109
  • 1
  • 2
    I think you're barking up the wrong tree. Look at how to configure sudo to not require a password for specific users/commands. –  Oct 06 '16 at 22:03
  • @yoonix Thanks, that pointed me towards searching for sudo without password and I've found something that looks like it'll do what I want. – KevinS Oct 06 '16 at 23:02

2 Answers2

1

Please spend your time doing something other than reinventing the wheel. There are a number of configuration management options these days.

The one closest to what you seem to be attempting to build is Ansible.

84104
  • 12,905
  • 6
  • 45
  • 76
  • Looks good but if I understand correctly it works by invoking commands on remote machines via SSH. Wouldn't I still be left with the same problem I described? – KevinS Oct 06 '16 at 22:56
  • [Yeah no.](https://docs.ansible.com/ansible/become.html) – 84104 Oct 06 '16 at 23:11
  • I had a chance to take a closer look at Ansible and it looks very good. Thanks for the tip. – KevinS Oct 08 '16 at 22:43
0

Anyway, without installing extra software should be possible, provided you have full control of the server where you deploy, or, somebody willing to help have it for you.

You're on the right path. Only missing point is modifying /requesting modify how your user use de sudo command. Its configuration option to establish that some users could use some sudo commands without a password being required.

Anyway docs are clear on how to do it, but if you do not own/administer the server where you deploy, will be strange (and risky) thatthe administratot provides you a "no password" sudo acces to something as powerful and complex like systemctl

mtsdev
  • 101
  • 1