Page 1 of 1

sudo: no tty present and no askpass program specified

Posted: Mon Oct 01, 2018 2:35 am
by missionaryman
Hi All,

Ubuntu 16.04.5 running VestaCP 0.9.8-22

I'm using a script to copy a backup file to dropbox. The script is stored in /usr/local/bin, has 0755 permissions and is owned by admin:admin.

Running the script from the command line works perfectly.

Setting it as a CRON job generates the following error:

sudo: no tty present and no askpass program specified

Any ideas how to fix this?

Thanks,
Adam

Re: sudo: no tty present and no askpass program specified

Posted: Mon Oct 01, 2018 3:50 am
by ScIT
not really vesta related, you will find a solution using google or take a look here: https://stackoverflow.com/questions/216 ... fied-error

Re: sudo: no tty present and no askpass program specified

Posted: Tue Oct 02, 2018 1:15 am
by missionaryman
I've used Google, extensively, to find a solution, to no avail.

The link you posted is not relevant to my situation. There are more relevant, VestaCP-related posts that ask similar questions, with a variety of answers, none of which work for me.

Anyone else?

Re: sudo: no tty present and no askpass program specified

Posted: Tue Oct 02, 2018 8:07 am
by ScIT
missionaryman wrote:
Tue Oct 02, 2018 1:15 am
I've used Google, extensively, to find a solution, to no avail.

The link you posted is not relevant to my situation. There are more relevant, VestaCP-related posts that ask similar questions, with a variety of answers, none of which work for me.

Anyone else?
The problem is, that the cron needs sudo permission and want to ask for the password. The link I've sent to you is exactly about this issue - maybe you can search a sys admin that can help you out at your issue.

Re: sudo: no tty present and no askpass program specified

Posted: Wed Oct 03, 2018 6:15 am
by mehargags
in your /etc/hosts put your hostname in front of 127.0.0.1

Re: sudo: no tty present and no askpass program specified

Posted: Sat Nov 23, 2019 1:42 am
by ralbrightii
I know this is slightly old, but it is still relevant. I have an install of VestaCP running on Ubuntu 18.04 LTS.

How exactly do I clear this up?

I have added the host names to 127.0.0.1 in the hosts file but editing the visudo I am still sketchy on. I have only had VestaCP loaded for a week, so I am sure these commands will get longer, but I am seeing emails for the following:
sudo /usr/local/vesta/vin/v-update-sys-queue backup
sudo /usr/local/vesta/vin/v-update-sys-rrd
sudo /usr/local/vesta/vin/v-update-sys-vesta-all

All of these are coming from the Cron Daemon.

Re: sudo: no tty present and no askpass program specified

Posted: Fri Dec 20, 2019 11:57 pm
by elamigosam21
I have recently started to get them too,
getting email from cron:
v-update-sys-rrd
v-update-sys-queue backup

also those scripts are listed under cron under a non admin user.
maybe I should remove them from that user since they are already listed in the user admin cron?

thanks

Re: sudo: no tty present and no askpass program specified

Posted: Sun Mar 08, 2020 9:55 pm
by menriquez
ok...since no one has solved this issue here ill go ahead and post the solutions.. ScIT had it right actually you just had to read what the StackOverflow article was saying.

so I have a CRON script that needs root at

Code: Select all

/home/admin/web/lasvegasluxerealty.com/public_html/rets
called

Code: Select all

do_full_rets_update
so the problem is that VESTA runs CRON under the admin user, so what should it do to run a root script since admin has never logged in?

the answer is in visudo...specifically run

Code: Select all

sudo visudo 
at the end, use the template

Code: Select all

username ALL = NOPASSWD: /fullpath/to/command
so in this case...

Code: Select all

admin ALL=NOPASSWD: /home/admin/web/lasvegasluxerealty.com/public_html/rets/do_full_rets_update
save the file with <esc>:w! and you should be GTG.

Re: sudo: no tty present and no askpass program specified

Posted: Mon Apr 06, 2020 3:13 pm
by Szektor
In my case removing "sudo" from cron command helped.
These commands usually run with admin /root privileges so no need for sudo.

This article is useful as well:
https://askubuntu.com/questions/590339/ ... -my-server

Contains:
How to find cron user?

Code: Select all

sudo grep -R "/usr/local/vesta/bin/v-update-sys-queue backup" /etc/cron* /var/spool/cron/crontabs
Silence a command like this (temporary solution to not get spammed by cron):

Code: Select all

*/5 * * * * sudo /usr/local/vesta/bin/v-update-sys-queue backup > /dev/null 2>&1

Re: sudo: no tty present and no askpass program specified

Posted: Thu Sep 10, 2020 5:01 pm
by elamigosam21
Maybe this helps someone,
I have several servers with vesta, from some I get this error, from others I dont,
what I discovered,
is that the servers that I dont get the error from, dont have those cron jobs listed, only sudo user (admin) have the cron job.
the servers that give this error are servers that have the cron job on users that dont have sudo permissions,

I think this happens when I import a admin account on a new server as a new non-admin user,
then the admin account cron jobs get imported, but since the user is not an admin the error gets generated.