Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

Is there any other way like command line parameter to ssh command (e.g. --password='asdf') or input redirection ("<") ?

share|improve this question

migrated from Nov 8 '09 at 14:25

This question came from our site for professional and enthusiast programmers.

I think SSH client has been engineered to prevent what you want to do. But I'm not fully sure. – Nicolas Goy Nov 8 '09 at 14:05
You might get better answers if you asked this question on – chakrit Nov 8 '09 at 14:10
@Nicolas please let me know that option, I am not able to find it in man page of openssh client. @chakrit I thought this as scripting question thats why I asked it here. – vinit dhatrak Nov 8 '09 at 14:12
You might also have a look at:… last answer. – Nicolas Goy Nov 8 '09 at 14:12
@Nicolas The answer mention use of another client like putty, but I want to use openssh client. – vinit dhatrak Nov 8 '09 at 14:15

I would have say to use RSA key or try this one: bare in mind that you need to install expect tool.

But since you have say NO to RSA and to expect, the only way is to write your own script utilizing Twisted's conch ( or any other platform available which offer SSH implementation such as ruby or Perl

share|improve this answer
I dont want expect script. Please read my question carefully. – vinit dhatrak Nov 8 '09 at 14:10
answer revised ;~) – Tzury Bar Yochay Nov 8 '09 at 14:20

You could try host-based authentication to log in without a password. In this case you don't need a private key for the user. But you still need a host key. Would this be a possible solution for you?

The man page of ssh sais:

Host-based authentication works as follows: If the machine the user logs in from is listed in /etc/hosts.equiv or /etc/ssh/shosts.equiv on the remote machine, and the user names are the same on both sides, or if the files ~/.rhosts or ~/.shosts exist in the user's home directory on the remote machine and contain a line containing the name of the client machine and the name of the user on that machine, the user is considered for login. Additionally, the server must be able to verify the client's host key (see the description of /etc/ssh/ssh_known_hosts and ~/.ssh/known_hosts, below) for login to be permitted. This authentication method closes security holes due to IP spoofing, DNS spoofing, and routing spoofing. [Note to the administrator: /etc/hosts.equiv, ~/.rhosts, and the rlogin/rsh protocol in general, are inherently insecure and should be disabled if security is desired.]

share|improve this answer

If you are familiar with Python, you can try paramiko.

share|improve this answer

In debian and derivatives, there's a package called sshpass (website here) that's designed to do exactly that.

share|improve this answer

You can also use The dropbear SSH client, which allows specifying the password on the command line, like this: Dropbear for automatic login for shell scripts

share|improve this answer

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.

share|improve this answer

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.)

share|improve this answer

You must log in to answer this question.