How can I do a non-interactive file transfer through sftp?
i.e without using password autentication.
( As we use "ssh -i <key> " option for passwordless access to the remote
host )
Thanks for any help
Regards
Subrat
On Wed, 16 Apr 2003 09:34:34 +0530
"spanda" <spa...@cisco.com> wrote:
> Hi,
>
> How can I do a non-interactive file transfer through sftp?
> i.e without using password autentication.
>
> ( As we use "ssh -i <key> " option for passwordless access to the remote
> host )
Looks like scp has the -i option also.
- --Alex
- --
PGP/GPG key id 848C80EF available at wwwkeys.pgp.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (OpenBSD)
iD8DBQE+nOZ0DryxAoSMgO8RAkK8AJ9vfsdpjLXrn4MyxNcx7qTigY4JtgCfff7T
eab1sDwP/BNQ/BhSX0tc/WI=
=LuKm
-----END PGP SIGNATURE-----
You use scp or "rsync -e ssh". sftp is Not Good(tm) for non-interactive use.
Others pointed out scp and rsync; still, it *is* indeed possible
to use sftp in non-interactive mode - or at least, it is possible
using OpenSSH's sftp.
Since sftp uses the ssh program for actually establishing the connection,
a properly configured SSH agent will definitely be used. For cases when
using an SSH agent is impossible or impractical, there is always
the '-o ssh_option' command-line argument to sftp: the following definitely
works for me:
[roam@straylight:p3 ~]$ sftp -o 'IdentityFile /home/roam/.ssh/id-online' localhost
Connecting to localhost...
sftp>
Note that you may have to use the -1 option if you have only set up
SSH protocol version 1 keys.
Also note that you could use the '-b batch_file' option for really
non-interactive processing.
The only problem I see with using OpenSSH's sftp in non-interactive mode
is that it would seem to be impossible to suppress the 'sftp> ' prompts,
and the echoing of commands in batch mode. Maybe scp is indeed preferable
after all :)
G'luck,
Peter
Please describe in detail where should I find (as most commonly put)
the 'IdentityFile /home/roam/.ssh/id-online' information? I mean maybe
my admin did not configure it well enough, I can't find the id
anywhere.
Thanks.
The original poster mentioned "ssh -i <key>". Take a look at
the ssh-keygen manual page, and at the answer to the 'How do I arrange
to log in without typing a password or passphrase?' question in
the FAQ at http://www.snailbook.com/faq/. The ~/.ssh/ directory is
where OpenSSH keeps all its per-user configuration by default,
including the keys, and ~/.ssh/id-online is simply my private key for
logging into a certain set of machines.
G'luck,
Peter
Thanks.
Now I am only working at the user-level to our system. I doubt the
admin in the ssh configurations, after I study the man-pages from
OpenSSH website (the admin did not even configure the man-pages). Now
I will write down what I understood your lines, then my specific
questions for my cases to seek for your input:
-- When installing ssh (OpenSSH), the admin should put the
"IdentityFile" somewhere for the ssh users to access. The
"IdentityFile" seems to be a small script like configuration file that
is set default to ssh, so that ssh may read through and identify the
allowable user and uses. Is it likely to be put in an "etc" directory
under the parent directory of where ssh is installed as default?
-- Your "id-online" file may actually your passwd to enter this ssh.
You use
sftp -o 'IdentityFile /home/roam/.ssh/id-online'
to let ssh know that you are running an option to let ssh seek for
your specified ID-key in the "IdentityFile" and your passwd in your
"id-online" file. Are users other than the admin allowed to use
ssh-ketgen to generate their own ID-keys?
-- Now my question is, if I am at user level, and the admin allow me
to use ssh, then the "IdentityFile" should be accessible to me. But on
our system, I don't even know where the "IdentityFile" file is. In
that "etc" directory, I find "ssh_config" file, and those
"IdentityFile ..." lines were remarkded (with # ahead) out. Does that
mean the admin does not want us to use it?
Next, I think I will have to go with the "public-key with plaintext
key file" option for my unattended ssh uses. Assuming that I can
resolve the "IdentityFile" problem, you mentioned that I will see
"sftp>" prompt all the time. I guess with a batch file of commands,
ssh will regard this "sftp>" simply as one "extra command". So will I
not get anything worst except for a sequence of "bad command"?
Thanks.
ColoC