0

Is there any way to login to another machine specifying the password in the script itself??

SSH-keygen wont work for me so i need to specify it in the script

  #!/bin/sh

    ssh root@201.1.192.21 mysqldump -uroot -pxxxxxx > backup/a.sql
Rajeev
  • 44,985
  • 76
  • 186
  • 285
  • if not use user keys maybe using host keys should be usefull, you can also specify key with -i option – mpapis Nov 15 '10 at 15:01
  • @Ignacio:Please see this http://serverfault.com/questions/200708/ssh-keygen-problem.I have problems in doing ssh-keygen – Rajeev Nov 15 '10 at 15:04

1 Answers1

0

You can use expect.

Reese Moore
  • 11,524
  • 3
  • 24
  • 32
  • I dont want to use expect.Script calling a script :) – Rajeev Nov 15 '10 at 15:11
  • Out of interest: why is that a bad thing? If that is disallowed don't boot your system because that is exactly how init works. – Reese Moore Nov 15 '10 at 15:26
  • @Reese there are many timeout problems associated with expect script – Rajeev Nov 15 '10 at 16:23
  • 2
    @Rajeev: Because there are security issues with passing passwords on the command line, `ssh` doesn't accept them as arguments. Using keys or `expect` is the way it's done. – Dennis Williamson Nov 15 '10 at 17:43
  • @Dennis I am learning about the various ways of automating interactive tasks through shell these days and still not sure which methods are secure. How does using expect do this securely? Can you confirm if expect would be the correct secure solution for this http://stackoverflow.com/questions/4594698/using-a-variables-value-as-password-for-scp-ssh-etc-instead-of-prompting-for-u? Thanks – Sandeepan Nath Jan 07 '11 at 06:44
  • @Reese - can you too check my question http://stackoverflow.com/questions/4594698/using-a-variables-value-as-password-for-scp-ssh-etc-instead-of-prompting-for-u please? I just want to confirm if expect would be the correct and secure solution for me – Sandeepan Nath Jan 07 '11 at 06:46