Home » Questions » Computers [ Ask a new question ]

How to use ssh from shell script without waiting for password?

How to use ssh from shell script without waiting for password?

I can not use public key method. I also don't want to use expect script. I searched this site for solution but everybody is talking about these solutions.

Asked by: Guest | Views: 286
Total answers/comments: 3
Guest [Entry]

If you are familiar with Python, you can try paramiko.
Guest [Entry]

Have a look at the ControlMaster option in ssh_config. This allows you to open a authenticated tunnel by hand that all following ssh connections uses.
Guest [Entry]

"If you have X running, you can write a tiny X code (e.g. in Tcl/Tk or Tkinter) that sends the password to stdout. Then all you have to do is set the environment variable SSH_ASKPASS to the path of that code.

from man ssh:

SSH_ASKPASS If ssh needs a passphrase, it will read the
passphrase from the current terminal if it was run
from a terminal. If ssh does not have a terminal associated with it but DISPLAY and SSH_ASKPASS
are set, it will execute the program specified by SSH_ASKPASS and open an X11 window to read the
passphrase. This is particularly useful when calling ssh from a .xsession or related script.
(Note that on some machines it may be necessary to redirect the input from /dev/null to make
this work.)"