I want to login using ssh and password store in a text file or may be in a varible

I am trying below method but i am getting an error please suggest me correct way.

echo "123456" | ssh root@127.0.0.1

error: Pseudo-terminal will not be allocated because stdin is not a terminal.

[![enter image description here](https://i.stack.imgur.com/SpBPj.png)](https://i.stack.imgur.com/SpBPj.png)