SFTP using user id and password

Hi,

I am using below syntax -

sftp -b passwordfile userid@ipaddress

passwordfile is a file, in which I have just kept a password of userid.

But by this, an error is coming like -
Permission denied (publickey,password,keyboard-interactive).

Please suggest me on this..as I dont want this in interactive mode, i want to pass password in sftp syntax only..

This is asked quite often in the forum - sftp is used either with entering password etc. manually or passwordless via key exchange.
The -b is to specify a batchfile that contains commands, not passwords.

Set up public keys which have been generated without entering a passphrase using ssh-keygen and try again.

Also scp might be more comfortable than sftp, if you have a choice.

I dont want to use keys..
Could you please help me If I can use password with the command itself..
Because I dont want interactive mode for connecting to other server.

Keys are much more secure than clear passwords stored in some file. It supports, as said already, usage of keys or interactive passwords. It does not support password supply from files!

Keys are easy, keys are secure, so why don't use keys...

If you still don't want to use keys, I can't help you :wink:

You can try

user=monalisha
passwd=xxxxxx
ip=1.2.3.4
lftp -u ${user},${passwd} sftp://${ip}<<EOF 
ls
bye
EOF

To fool a program into thinking that it's running in interactive mode, use expect. Or use a pty wrapper like a perl module or write a C program.

If you don't want an interactive login, why are you trying to use interactive password authentication? Use pre-shared keys. That's what they're there for.

ssh is designed to stop you from shoehorning in stored plaintext passwords; you really have to go out of your way to fake it well enough to fool it. This is a subtle hint written in mile-high flashing neon letters. You're not supposed to do this. Stored passwords are obsolete. There's better ways to do what you want, ways that do exactly what you want without the fundamental security flaws of storing passwords.