I have SSH target machine with RHEL os where I defined an account to connect to this target. I’m able to connect successfully and executing some script commands, but when I’m using sudo command “sudo su - username” nothing happened and Octopus deploy stuck on this step without any error message.
Can you help why sudo command is not executing?
Thanks for reaching out.
The first thing that jumps out to me is that the terminal might be waiting for the sudo password. Can you please confirm that the account you have setup to SSH into your linux box is setup for Password-less Sudo?
Please let me know.
Thank you @jeremy.miller for your reply.
I confirm that octopus account is using password-less sudo, I tested this directly from a ssh session.
I just trying to run this command “sudo echo “I HAVE THE POWER”” from Octopus step, I got the below output, but same issue still exist using “sudo su - username”
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
sudo: no tty present and no askpass program specified
You’re very welcome.
Can you please run
cat /etc/sudoers | grep the_tentacle_username and let me know the output?
I executed the command “cat /etc/sudoers | grep octopus”
and this is the output “User_Alias APP = octopus”
Initially I configured the target as SSH target and sudo was not working.
Now I installed Octopus Tentacle on the target and service is running under root account but when I run"
“sudo su - serviceaccount”
the step completed but still showing the the user is the root user
Thanks for the information.
I think what we have to do to get this to work is to run
sudo su -c and run single commands. If we don’t pass that -c parameter it opens up a new interactive shell window which will fall into the void in an Octopus deployment.
–c or –command [command] – Runs a specific command as the specified user.
Please let me know if you can give that a shot and how it goes.
I’d like to thank you as using “sudo su -c” works fine and I’m able to execute commands under a specific user. I’ll use this as a temporary solution for now.
I’m curious to know the reason why normal “sudo su” is not working and causing Octopus to stuck in the step in case of SSH target and not executing in case of tentacle.
as keeping passing commands line by line with " sudo su -c" is not the best solution.
Thanks again for your valuable support.
Thanks for letting me know it worked for you.
Unfortunately, due to tentacles only working in non-interactive mode, using sudo su without the -c parameter will cause the commands following sudo su to not run in the desired shell. All of the commands will be run in the first shell, and running sudo su opens a second interactive shell.
Visually you can see the shift here:
Anything you put in your bash script after sudo su will attempt to run in the green shell, not the white one.
Please let me know if I explained that okay.
It’s possible that there might be a different angle we can approach this from, if you can let me know what your high-level use case is for running many commands with sudo su as another user.
I’d like to thank you again for the solution tip using “su -c” it saves my time and efforts, I was about to find another workarounds where it will not be easy and not secure to implement.
Sure, your answer is enough for me to get the idea why “sudo” is not executing"
Hi @farouk.sabry ,
You’re very welcome. Thank you for updating me.
Please let me know if you have any other questions or concerns, and I hope you have a great rest of your week.
Thank you @jeremy.miller , all went fine with me.
You can close the topic
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.