-1

I have a file in my remote server which needs to be transferred to sftp box. I do have the password, port and username for sftp box.

Please share me a shell script programming to understand how this can be done.

Drella
  • 9
  • 4
  • You mean `sftp -P port user@host:filename`? (note: you are better off using `rsync` which has similar syntax and is far more capable) – David C. Rankin Nov 03 '17 at 02:48
  • I need to use only sftp. – Drella Nov 03 '17 at 02:55
  • there are many examples already available here and elsewhere on the internet. You should try searching for them. Requests for free coding are off topic here on StackOverflow. Please read https://stackoverflow.com/help/on-topic , https://stackoverflow.com/help/how-to-ask , https://stackoverflow.com/help/dont-ask , https://stackoverflow.com/help/mcve and take the [tour](https://stackoverflow.com/tour) before posting more Qs here. Good luck. – shellter Nov 03 '17 at 03:32
  • 1
    If you look at the right side of the page under **Related**, you will find [How to run the sftp command with a password from Bash script?](https://stackoverflow.com/questions/5386482/how-to-run-the-sftp-command-with-a-password-from-bash-script) and [How to retrieve a file from a server via SFTP?](https://stackoverflow.com/questions/14617/how-to-retrieve-a-file-from-a-server-via-sftp?rq=1) It will lead you through it. – David C. Rankin Nov 03 '17 at 05:52
  • 1
    Possible duplicate of [How to run the sftp command with a password from Bash script?](https://stackoverflow.com/questions/5386482/how-to-run-the-sftp-command-with-a-password-from-bash-script) – David C. Rankin Nov 03 '17 at 05:55
  • This is too vague. What is "remote server"? How do you access it? Where do you need to run the transfer script? On the local machine? What kind of machine is that? Or on the remote machine? What kind of machine is that? Anyway, your question would better fit in [su]. But before you re-post it there, read all the links in other comments above. And if you decide to re-post there anyway (after deleting this copy), make sure you include answers to all my questions to the new post. – Martin Prikryl Nov 03 '17 at 07:01
  • Thanks all for coming back. I looked into the suggested links again.But I am not looking for command, I am looking for batch script which when triggered manually on the remote machine which is a linux box, I have the authorization credentials for this box. I also have the sftp details of username, password, port. i referred already posted ones, i didnot find any suitable answer so posting it again. – Drella Nov 03 '17 at 13:22

1 Answers1

0

you can go for passwordless authentication between remote server and sftp box via sharing the public key . OR , you can use scp filename sftpuser@sftphost:/$destination_Path

tech_help
  • 42
  • 1
  • 1
  • 6