View Single Post
  #2  
Old 10-03-2007, 04:18 AM
unix unix is offline
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: I can sftp (with password) but not sftp -b - not prompted for password!

In article <1182899456.855531.325420@o11g2000prd.googlegroups. com>
usenet@DavidFilmer.com writes:
>I am trying to sftp data to a server. I only have the option to use
>password authentication.
>
>I can sftp just fine to the server and do whatever I want.
>
>However, if I try to sftp with a batch file, I am not prompted for my
>password. It seems to just skip that option.


It's a design decision, not a good one in my opinion. At some 3.x
version, this was added to sftp.c:

case 'b':
...
>>>>>>>>>> addargs(&args, "-obatchmode yes");


From ssh_config(5):

BatchMode
If set to ``yes'', passphrase/password querying will be disabled.

It is also documented in sftp(1) (at least in current versions):

-b batchfile
Batch mode reads a series of commands from an input batchfile
instead of stdin. Since it lacks user interaction it should be
used in conjunction with non-interactive authentication.

IMO, if a 'sftp -b' user wants to disable passphrase/password querying,
he can just use that -o option on the sftp commandline himself - there
are many scenarios where interactive authentication is just fine even if
you prefer to have the sftp commands in a file.

I guess this is unlikely to change though, and given that, it is now
possible to do the opposite, i.e. override the "builtin" BatchMode
setting on the sftp command line:

sftp -o "batchmode no" -b /tmp/bat user@host

Note that it must come *before* -b, which may be surprising - this is
due to ssh processing -o options as if they were read from the config
file - ssh_config(5) again:

For each parameter, the first obtained value will be used.


--Per Hedeland
per@hedeland.org

Reply With Quote