0

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?

starkshang
  • 8,228
  • 6
  • 41
  • 52
Confusion
  • 39
  • 1
  • 9
  • 1
    Possible duplicate of [Automatically Enter SSH Password With Script](http://stackoverflow.com/questions/12202587/automatically-enter-ssh-password-with-script) – Kenster Dec 22 '15 at 12:48

1 Answers1

0

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 "
Pratik Anand
  • 667
  • 5
  • 11