Skip to content

Using yay --sudoloop, how can I pipe password to it?

Hi there, Is there away to pipe sudo password to yay or paru with sudoloop?

I've tried the following but non worked for me

echo "password" | yay -S --sudoloop --noconfirm pkg(s)
printf "password" | yay -S --sudoloop --noconfirm pkg(s)
echo "password" | sudo -u user yay -S --sudoloop --noconfirm pkg(s)
yay -S --sudoloop --noconfirm pkg(s) <<< password

it works okay with sudo -S, but otherwise it just skips.

Thanks

2 points11 comments
Open on Reddit
About this post
Posted
Archived
Score
2 · 67% up
Kind
Text
ID
kfbcvi

Author

19
posts
101
comments
1
media
View profile

11 comments

What is it you're trying to achieve?

echoing your password is generally a bad idea - it will become visible to anyone with access to your shell's historyfile (well, this is easy to avoid) and to your process table.

6 points

Run installation script with a list of aur and official packages

1 points

Okay, so you wrote an installation script and want to run this? I think the best option would be to let sudo ask for the password once at the beginning of the script (for example with a sudo id) and then use yay with the --sudoloop option.

Another option as /u/parkerlreed suggested is to allow your user to run pacman as sudo without having to enter a password.

your_username ALL= NOPASSWD:/usr/bin/pacman in your sudoers file should work. See https://wiki.archlinux.org/index.php/Sudo#Example_entries

Last option: use something like echo 'your_password' | sudo -S -k in your script and then use yay with --sudoloop option. This is not secure, as your password will be stored in plaintext in your script.

As a general rule: if you want to solve a problem always describe your original problem and include as much information as possible. It's way better than just asking why your solution does not work.

6 points

you can just use makepkg instead. you don't need to use yay to install/build from AUR. I don't know from memory but if makepkg requires you to build using non-root user you can just sudo -u nobody or something along those lines to build with a user without permissions.

1 points

Or you could just set NOPASSWD for pacman. Not ideal but a hell of a lot better than having your password exposed in plain text.

4 points

Doesn't sudoloop just "save" the password for the duration of the yay command, meaning you dont have to re-enter it? I mean it seems what you are trying to do is just the standard behaviour of paru...?

3 points

sudoloop in yay and paru just runs a command with sudo on an interval during long builds. It keeps the sudo timeout from expiring. yay/paru are never aware of your password.

2 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.