1

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 [email protected]

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

enter image description here

Tiger
  • 648
  • 7
  • 12
  • 25

2 Answers2

2

Ideally, you would want to use ssh keys instead of a plaintext password stored in a file/script. This looks like a duplicate of https://stackoverflow.com/questions/4594698/using-a-variables-value-as-password-for-scp-ssh-etc-instead-of-prompting-for

Jason Rush
  • 1,808
  • 1
  • 11
  • 12
1

Install sshpass with below commands.

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/sshpass-1.05-1.el6.x86_64.rpm

 rpm -ivh sshpass-1.05-1.el6.x86_64.rpm

Now login with ssh

sshpass -p ‘password’ ssh root@IP

amit singh
  • 420
  • 5
  • 10