LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-03-2009, 04:47 AM   #1
ZAMO
Member
 
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 598

Rep: Reputation: 30
Unable to upload using ncftpput


Hi all,

I got a new issue to discuss and fix it.
When i try to upload a file by manually login to mysftp and
put the files , they are getting uploaded.

When I do the same by writing a script, its showing me Connection refused.

Code:
/usr/local/bin/ncftpput -f  mysftppasswd.conf $source_dir $destination_dir

I tried the same in the shell also, using the absolute path of source and designation, but its not working.

Am I doing the right thing here. Did anyone come across this before.

Cheers
 
Old 02-03-2009, 05:06 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by ZAMO View Post
When i try to upload a file by manually login to mysftp
What is mysftp? If your server uses the secure shell ftp (sftp - default port 22) you cannot use the ncftp client to upload files, since it implements the normal ftp protocol (port 21).

In other words: which command did you use to successfully upload the file?
 
Old 02-03-2009, 05:33 AM   #3
ZAMO
Member
 
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 598

Original Poster
Rep: Reputation: 30
To manually upload the file to sftp am using the following :

Code:
sftp myuser@sftp
passwd:xxxxxx
cd desination_dir
put files_to_upload
exit
As ncftpput will work on sftp , Is there any similar way to upload the file in sftp?
 
Old 02-03-2009, 05:47 AM   #4
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Hi,

Take a look at scp
http://kb.iu.edu/data/agye.html
 
Old 02-03-2009, 05:48 AM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Yes. You can try the option -b of sftp to put your commands in a batchfile. The only limitation (which is actually an improvement of the security of your systems) is that you cannot provide username and password, but you have to setup Public Key Authentication or eventually Host Based Authentication, that is either one of the two available non-interactive authentication methods. Here is an excerpt from man sftp:
Code:
-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.  A
             batchfile of ‘-’ may be used to indicate standard input.  sftp will abort if any of the follow-
             ing commands fail: get, put, rename, ln, rm, mkdir, chdir, ls, lchdir, chmod, chown, chgrp,
             lpwd and lmkdir.  Termination on error can be suppressed on a command by command basis by pre-
             fixing the command with a ‘-’ character (for example, -rm /tmp/blah*).

Last edited by colucix; 02-03-2009 at 05:49 AM.
 
Old 02-03-2009, 06:32 AM   #6
ZAMO
Member
 
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 598

Original Poster
Rep: Reputation: 30
CoLucix,

I tried to do this using a batch file and failed. The format i used is

user_passwd
put filenames

Its showing me "Invalid buffer size "
 
Old 02-03-2009, 07:21 AM   #7
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You cannot put user and password in the batch file. You can use it with Public Key Authentication, only. Anyway, the error message is really strange in this case. Can you post the exact command line you used?
 
Old 02-03-2009, 07:29 AM   #8
ZAMO
Member
 
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 598

Original Poster
Rep: Reputation: 30
Its

Code:
sftp -b path-to-my/mybatch.conf

Colucix,

Its not easy for me to do Public Key Authentication as it dependencies (mean ,lot of ftp servers) goes beyond.

Am almost shocked by that we cannot upload files from the shell to our sftp using ncftpput. May be gaining this knowledge too late is mine


Got struck again
 
Old 02-03-2009, 08:26 AM   #9
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
The problem is intrinsic of the secure shell: you cannot pass username and password in clear text so you cannot write them in a script or in the command line, otherwise the advantages of using the secure shell are lost. Anyway, you can try expect a Tcl extension to take actions when an interactive response is expected. You have to write an expect script and tell the script to negotiate the password when the server on the other side requires it.

Again, the security concern of the secure shell is lost, but if you don't have any other alternative, at least be sure your script is not world readable. Here is an example of a script which uses expect to perform a sftp section. If you google for expect + sftp you will find plenty of them.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
vsFTPd Help (Unable to Upload) carlosinfl Linux - Server 1 11-06-2008 10:42 AM
vsftpd - unable to resume upload DBabo Linux - Software 0 09-11-2007 02:20 PM
VSFTPD unable to upload/download as anonymos linuxmandrake Linux - Software 0 02-25-2006 05:51 AM
unable to upload using copy php helpme0904 Linux - Newbie 5 01-06-2006 02:23 PM
vsftpd - virtual users unable to upload frodema Linux - Networking 3 12-06-2003 07:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration