Hiding stdin input for sudo -S via ssh?

Im using the command
ssh host@ip.ip.ip.ip "sudo -S dd if=/dev/mmcblk0 ...
to backup a RaspberryPis SD card while its running through ssh.

I don’t want to change anything on the RPi (like e.g. sudoers) and if i do not use the option -S i get the well known issue that no TTY or askpass is defined.
I also tried to set the SUDO_ASKPASS env. variable which did not lead to success

Thats why im glad that the upper version with using sudo -S is working because it asks me for the sudo password, which is then provided via stdin

The problem is, that the backup through ssh takes a long time which means that the “not-hidden” password i typed in can be seen on my screen for a very long time

Is there a possibility to hide the input?

What about working with ssh-keys instead of passwords?

I dont know what you mean but im already accessing the Raspberry Pi without password because i generated a ssh-key etc.

I think the reason i need a password here is the “sudo”-command wich always needs a pasword at first

Why not log in as root with ssh-keys. After that no sudo is required.

1 Like

(2nd fastest :rofl:)
When you use a key, it is possible to add the key to the root account on raspi. Then you will not need to use sudo at all.

changes to:

ssh root@ip.ip.ip.ip "dd if=/dev/mmcblk0 ...
No password seen at all

2 Likes

I will try to manage this in the coming days
Thanks to both of you

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.