1

I want to login to remote computer using shell script through ssh, i want to pass username and password from text file. how to do that?

here is code what i have tried.

 #!/bin/sh
    #
    username=user
    ip=192.168.2.21
    ssh $username@$ip < user.txt
2
  • And you don't want the script file to be the text file? Why not? It looks like you are proposing to have a file full of user names and (plain text) passwords in a directory that is readable. DANGER! Commented Apr 15, 2013 at 5:12
  • 3
    Take a look at ssh keys, they solve your problem in a much more elegant and secure way. Commented Apr 15, 2013 at 5:14

1 Answer 1

1

You can't SSH in the method that you're referring to. You will want to use SSH keys which are created to help with what you're doing.

Also, avoid storing your password in a text file.

Sign up to request clarification or add additional context in comments.

Comments