Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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*).
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.