Join Nostr
2026-02-19 23:40:17 UTC

A wizard did it :donor: 🇨🇦 on Nostr: Better programmers than me, show me a less sketchy way to do this. I'm trying to make ...

Better programmers than me, show me a less sketchy way to do this. I'm trying to make a bash script that will copy a file to a machine, then ssh into it and run a list of commands as sudo. All of these use password authentication (I know, don't ask), and I cannot login as root. I cannot think of a way to pass the password through the ssh tunnel so that it can be read on the other side. All I've come up with so far is to do this:#!/bin/bash<br>servers=$(cat servers.txt)<br>for cpu in $servers; do<br>ssh -t $cpu &lt;&lt; 'EOF'<br>echo "[SUDO PASSWORD]" &gt; ./pass<br>cat pass | sudo -S [all the rest of my commands here]<br>rm ./pass<br>exit



This works, but oh baby is that a sketchy way to do things and there has to be a better solution to this.

#bash #linux