1

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 ("<") ?

8
  • 3
    I think SSH client has been engineered to prevent what you want to do. But I'm not fully sure.
    – Nicolas Goy
    Nov 8, 2009 at 14:05
  • You might get better answers if you asked this question on serverfault.com
    – chakrit
    Nov 8, 2009 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, 2009 at 14:12
  • You might also have a look at: stackoverflow.com/questions/459182/… last answer.
    – Nicolas Goy
    Nov 8, 2009 at 14:12
  • @Nicolas The answer mention use of another client like putty, but I want to use openssh client.
    – vinit dhatrak
    Nov 8, 2009 at 14:15

7 Answers 7

2

I would have say to use RSA key or try this one: http://bash.cyberciti.biz/security/expect-ssh-login-script/ 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 (http://twistedmatrix.com/projects/conch/documentation/examples/) or any other platform available which offer SSH implementation such as ruby or Perl

2
  • I dont want expect script. Please read my question carefully.
    – vinit dhatrak
    Nov 8, 2009 at 14:10
  • answer revised ;~) Nov 8, 2009 at 14:20
2

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

2

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

2

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

1

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

0

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.

-1

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

You must log in to answer this question.