Linux for beginners-SFTP a file


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Linux for beginners-SFTP a file
# 1  
Hammer & Screwdriver Linux for beginners-SFTP a file

I need help writing a simple SFTP shell script to transfer a few files. What I have is server info of the remote computer I will be sending the files to. Please help I am new to the shell/linux stuff.

Code:
Example: Password: 1234
         User:     We1234
         We12345@hostname.com


Name of files I want to transfer: RED*
Where I want to drop the files: FOLDER_2017

Last edited by rbatte1; 07-31-2017 at 01:21 PM.. Reason: Removed (auto?) email tags and wrapped in CODE tags to preserve multiple spaces for indenting.
# 2  
You have to set up ssh keys on both the local and the remote boxes FIRST.
Then you can use passwordless file transmission.

Debian example, works almost anywhere:
How to set up ssh so you aren't asked for a password
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Hello Yanisol,

Below a little script which should do the work:

Code:
#!/bin/bash

user_sftp="We1234"
pass_sftp="1234"
server_sftp="We12345@hostname.com"


cd /file2transfert/

sshpass -p $pass_sftp sftp $user_sftp@$server_sftp << !
cd FOLDER_2017/
mput RED*
exit
!

Hoping have helpedSmilie
# 4  
Thanks for making a suggestion Arnaudh78, but this would leave a few security issues:-
  • The credentials are plaintext in the script
  • The credentials will be plaintext during the execution of sshpass
I would strongly recommend using the suggestion of jim mcnamara which keeps your credentials more secure. Of course, you have to ensure that no-one steals your private key, but that is a requirement of the set up anyway.



Kind regards,
Robin
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #985
Difficulty: Medium
386BSD and FreeBSD were both derived from BSD releases.
True or False?

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Which Linux Certification comes first for beginners?

I want to get a Linux Certification to start my Career in IT sector. My Qualification is MCS from a top university. Suggest me some Linux Certifications. (1 Reply)
Discussion started by: alexwatson1711
1 Replies

2. UNIX for Beginners Questions & Answers

Sftp connection not establishing from Linux to DataPower

Hi Everyone, I am trying to send files from Linux to DataPower server using public key based authentication but it's not working as expected and every-time password expecting for sftp transfer. Can someone please help on this? Steps I fallowed: Created keys pair at source server... (4 Replies)
Discussion started by: renukeswar
4 Replies

3. Red Hat

SFTP to VM Linux

Hi . We have customer users uploading sales data in excel format in a portal, once this file is uploaded a batch process will SFTP the file from here to a linux virtual machine and then to the mainframe . We are seeing that there are many cases where all the rows the user entered in excel file... (1 Reply)
Discussion started by: ron5174
1 Replies

4. Linux

SFTP files to a server from Linux.

Hi, I am looking for a shell script to sftp to a file server and copy all the files from a directory after the script is run. The server name should be a user input parameter and of-course the username/password as well. Rest all should be handled by the script. I tried with below snippet:- ... (1 Reply)
Discussion started by: happysingh
1 Replies

5. UNIX for Advanced & Expert Users

Sftp working on Linux but error on HP UX

Hi the below two line in my sh work fine in Linux but when I run it in HP UX it throws error saying "No such file or directory (-)." can anyone pleas let me know what is wrong. Any help is appreciated. INPUTFILE="$(echo ls -1t | sftp -b- $SFTPSERVER:$SFTPDIR |grep ^LK| head -1)" echo... (1 Reply)
Discussion started by: murtymvvs
1 Replies

6. Shell Programming and Scripting

File locking (Unix/Linux) & sftp

Hi all, Can anyone help ...on how to ensure that a file is locked . thanks & regards, Soodoo ---------------------------------------- Problem description: - We usually use the mv command in scripts to make sure that a file is complete and not being written to by another process. ... (1 Reply)
Discussion started by: soodoo
1 Replies

7. Emergency UNIX and Linux Support

solaris or linux sftp/ftp-server

Hi, we have a big problem, history: we migrated our companies ftp and sftp-server, which were vsftp and openssh, to one server, software is called JSCAPE ftp server professional edition for the first time everything was great, but after one or two months, our uploads hang, 0 byte files are... (11 Replies)
Discussion started by: funksen
11 Replies

8. Windows & DOS: Issues & Discussions

How to connect SFTP(Linux) from Windows DOS

I need to write a batch script for file transfer from SFTP to Windows system. SFTP is on Linux system. I kept this code in batch file and executing it.. but not working.. Even i tried from Command prompt like this "open sftp.host.com" but getting error. Can anyone help with the code and tell me how... (15 Replies)
Discussion started by: mohantmk
15 Replies

9. Shell Programming and Scripting

SFTP vs FTP and going UNIX to LINUX

I have automated an ftp process that FTP's files from one UNIX box to another in the following format: ftp -n -v $REMOTE_SERV << EOF user $FTP_USER $FTP_PASS cd $REMOTE_PATH put $CUR_NAME $NEW_NAME bye But how can I accomplish this SFTPing from a UNIX box to a LINUX box? I've seen... (4 Replies)
Discussion started by: TimBurke
4 Replies

Featured Tech Videos