Confusion
Confusion

Reputation: 29

Shell Script to access a remote machine using ssh with usr and pwd both

I am writing a shell script that can connect to another remote machine and query the DB , write the result in a file and copy the file back to main machine. I am facing issue while connecting to DB. I am not understanding how to connect to the remote machine. I am using ssh root@DB_IP the then ORACLE query. But its always asking a password. How to provide both username and password while doing a ssh to the remote machine?

Upvotes: 0

Views: 275

Answers (1)

Pratik Anand
Pratik Anand

Reputation: 687

You can do this by two ways:-

  1. By adding your id.rsa.pub in your remote machine (~/.ssh/authorized_keys)
  2. sshpass -p password ssh root@ip "sh run.sh "

Upvotes: 0

Related Questions