I have Ubuntu OS with encrypted partition. During boot, I want to download keyfile from remote server using scp and use it to decrypt partition.

What I did:


#PREREQS blah blah

mkdir ${DESTDIR}/usr
mkdir ${DESTDIR}/usr/bin
cp -pnL /usr/local/bin/dropbearmulti ${DESTDIR}/bin/dropbearmulti #compiled dropbear ssh/scp client
cp -pnL /etc/initramfs-tools/root/.ssh/* ${DESTDIR}/root/.ssh #copy keys/known_hosts to image


ln -s /bin/dropbearmulti /usr/bin/dbclient #symlink for dbclient (need to make scp work)
export HOME=/root
/bin/dropbearmulti scp user@host:/home/user/file /tmp/file

Network is configured, everything is fine. When it executes scp, I see prompt where I need to enter password, but I can't do so (it hangs) boot process is stuck.

I've tried to use plymouth:

/bin/plymouth ask-for-password --prompt "Specify password: " | /bin/dropbearmulti scp user@host:/home/user/file /tmp/file

It was asking for password, I was able to input it and submit, but it didn't pass it to scp (scp again asked for password and got stuck)

How can I pass password from stdin to scp command?



I don't know how much security you need, but one option is to serve the key file over HTTPS, in a password protected directory. You can include curl in the initramfs and use it to download the key file. I guess it would be less cumbersome than SSH to accept passwords from variety of sources.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.