password for ssh and scp

Solution 1:

Use a key file. Place the private keyfile on your client and use ssh-agent to keep the key file loaded in memory, decrypted. Place the public key file on each of the systems you want to access.

Use authentication forwarding to create connections between various hosts without being prompted for authentication.

Solution 2:

scp/ssh will test the input stream to check if it is a TTY and if not will try alternate ways to get the password, so plain piping will not work (because the pipe is not a tty).