How to transfer a file using sftp in UNIX
NickName:Robin clave Ask DateTime:2013-04-04T18:13:35

How to transfer a file using sftp in UNIX

I want to transfer a .png file from a directory on my computer to a directory on a remote server.

I have to use SFTP to secure the file and transfer mode. And I already have a UNIX script (.ksh) file to copy the files in the normal mode. How do I implement the transfer in SFTP mode?

Copyright Notice:Content Author:「Robin clave」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/15808381/how-to-transfer-a-file-using-sftp-in-unix

Answers
Shimon Rachlenko 2013-04-04T10:25:07

Use sftp instead of whatever command you are using in your .ksh script. See sftp man for reference.\n\nYou may also want to look at scp secure copy - scp man.\n\nEDIT\n\nsftp is mostly for interactive operations, you need to specify host you want to connect to: \n\n\n\nsftp example.com\n\n\nyou will be prompted for username and passsword, and the interactive session will begin..\n\nAlthough it can be used in scripts, the scp is much more easy to use:\n\n\n\nscp /path/to/localfile user@host:/path/to/dest\n\n\nyou will be prompted for password..\n\nEdit 2\n\nBoth scp and sftp use ssh as underlying protocol, see this and this\n\nThe best way to setup them to run from scripts is to setup passwordless authentication using keys. See this and this. I use this extensively on my servers.. After you setup keys, you can run\n\n\n\nscp -i private-key-file /path/to/local/file user@host:/path/to/remote\n\nsftp -oIdentityFile=private-key-file -b batch-file user@host\n\n\nIf you want to authenticate with password, you may try the expect package. The simplest script may look like this:\n\n\n\n#!/usr/bin/expect\nspawn sftp -b batch-file user@host\nexpect \"*?assword:*\"\nsend \"pasword\\n\"\ninteract\n\n\nSee this, this and this for more info.",


More about “How to transfer a file using sftp in UNIX” related questions

How to transfer a file using sftp in UNIX

I want to transfer a .png file from a directory on my computer to a directory on a remote server. I have to use SFTP to secure the file and transfer mode. And I already have a UNIX script (.ksh) ...

Show Detail

SFTP Transfer completion status

I have a SFTP code to get file from the remote server to my local server using "expect".Below is the snippet from my shell script. /usr/bin/expect<<EOF spawn /usr/bin/sftp -o Port=$PORT $US...

Show Detail

Transfer file and change user using Java to unix box

I want to transfer file from windows to unix(linux) box using Java, then change to super user. I tried using the JSCH library, that is SFTP with java. I am stuck at the step to change to super us...

Show Detail

Sftp unix batchfile

Intitally i wrote below script to do sftp using rsa keys,i mean without password. Now i want user/password authentication first then RSA public key authentication.What amendments required in below...

Show Detail

How to transfer file with SFTP using OpenSSH in SSIS?

In my project I have to use OpenSSH sftp tool to transfer file using SFTP and it should be executed from SSIS. I searched a lot from last one month but not able to find any solution. I did transfer...

Show Detail

Progress bar for file transfer from Unix to Java

I know this question sounds repeated but the difference is that i am trying to implement progress bar for Unix-Java file transfer.I am using below code for downloading the file from Unix to my loca...

Show Detail

Net::SFTP Transfer Mode (Binary vs Text)

Is there a way using the Net::SFTP Library in Ruby (API Link) to set the Transfer Mode to Binary? I am unforunately on a windows system and am uploading a UTF-8 file to a Unix system. The ruby libr...

Show Detail

How to transfer binary file in SFTP?

How to transfer binary file in SFTP? Will it be same as normal file? Or is there any different process?

Show Detail

SharpSSH - How to set permissions when using Sftp.Put

I'm using SharpSSH to write files to a unix machine. The files are supposed to be read and then deleted up by another application which resides on the unix machine. The problem is that the unix

Show Detail

Python 3.5 SFTP file transfer

I would like to use paramiko for SFTP file transfer in Python 3.5. I know that paramiko depends on PyCrypto and have read about PyCrypto installation problems in Python 3.5. Although I have seen a ...

Show Detail