user1960932
user1960932

Reputation:

how to read username & password from file in shell script?

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

Upvotes: 1

Views: 1833

Answers (1)

user835223
user835223

Reputation:

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.

Upvotes: 1

Related Questions