Shell script to transfer file via SFTP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script to transfer file via SFTP
# 1  
Old 11-15-2012
Shell script to transfer file via SFTP

Hi all,

I'm trying to do a script to transfer file between my server and an external server via SFTP protocol. It doesn't use rsa key, but password.

When I run the script, it throw back a prompt that request me to put the password. How should I do for automatic login? Pleaes help Smilie

Thanks you in advance
Code:
#!/usr/bin/sh
user=cmsusr
pass=cmspwd
ip=10.xxx.xxx.xxx
log_file = ./pom_log
sftp -oport=40 $user@$ip << EOF >> $log_file
quote ${pass}
bye
EOF

# 2  
Old 11-15-2012
Try searching the forums. There are several answers that you can use.
# 3  
Old 11-15-2012
You should not be trying to inject plaintext passwords into sftp. That it's so difficult to do is actually a subtle hint, writ in mile-high flashing neon letters, that it's a really, really bad idea. Retrievably-stored passwords are almost impossible to keep safe. "Interactive password authentication" means "Password typed by a human being in realtime authentication" and no artificial substitutes for humans are acceptable. It insists on it being input to a terminal.

Use ssh keys, that's what they're there for.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Execute a script after SFTP transfer

Hi All, I am having an issue with the script execution. I am having a SFTP process that send files to a location . I want to execute a script once it transfer the file to that location. Right now I am leveraging autosys file watcher to do that. Is there any way like MFT PPA that can execute... (2 Replies)
Discussion started by: arunkumar_mca
2 Replies

2. Shell Programming and Scripting

Shell script, sftp logfile not showing transfer information

Hello, Recently I have changed some crontab scripts which I execute to do different tasks mainly transfering some files from one server to the other. The main change was the protocol from ftp transfer to sftp. Ftp server was the MS Windows default service, and Sftp server is an proprietary sw... (4 Replies)
Discussion started by: enux
4 Replies

3. UNIX for Dummies Questions & Answers

SFTP File transfer issue

Hi guys, Need a quick and urgent help on below issue. One of our application is try to transfer the file to another host thru sftp process My file is about 1 GB. Job is getting hung while transferring the file. So when I login as sftp and check the file system space is only in MB... (2 Replies)
Discussion started by: Vinoth Kumar G
2 Replies

4. Shell Programming and Scripting

File transfer using SFTP

Hi, I want to a transfer file from remote machine to a local machine using SFTP where both my local and remote machines are Ubuntu machines.So i wanted to write a unix bash script which uses SFTP command to transfer the file from remote to local machine. My remote server is 178.28.30.106. ... (14 Replies)
Discussion started by: shree11
14 Replies

5. Shell Programming and Scripting

Passwordless file transfer using sftp

Hello all, I have a requirement, in which we need to stage a package to Unix remote server in an automation (we cant use ssh key generation) , do u have any idea how we can transfer the package to remote server using sftp .if you have any script plz share it to me (4 Replies)
Discussion started by: Ramji Sundaram
4 Replies

6. UNIX for Dummies Questions & Answers

Problem automating sFTP transfer using script in cron

Hi Newbie here I am having problems with automating sFTP transfers. Just to save time - SCP is not an option as sFTP is stipulated by controllers of far end server. Ineed to automate sFTP transfer of a single file, once a day to a remote server to which i have no control over. I am using:... (6 Replies)
Discussion started by: robbien
6 Replies

7. Shell Programming and Scripting

SFTP with ASCII file transfer

Hello - I have text file and need to load the data in Oracle through sqlloader. I need to move this file to unix server and load into oracle. When i SFTP(unfortunately i do not have FTP) to unix box, each line is appended with ControlM character... since it is transferring in BINARY... (4 Replies)
Discussion started by: govindts
4 Replies

8. Shell Programming and Scripting

sftp file transfer

hi i am trying to login to remote server using SFTP Protocol and trying to upload a file butit is asking for the password. Note: I am trying to connect to FrontEnd server sftp SFTREGUP1@14.71.26.6 Connecting to 14.71.26.6... Password Authentication Password: Please help (14 Replies)
Discussion started by: Satyak
14 Replies

9. UNIX for Advanced & Expert Users

sftp command for file transfer

hi, I need to sftp a file from one unix system to another unix system. eg: filename is test.txt servername : abc@xyz please give me the sftp command for that. thanks in advance.. mohan.p (2 Replies)
Discussion started by: mohanpadamata
2 Replies

10. Shell Programming and Scripting

How to transfer files (By using generic script) when using sftp

I have written generic script to transfer files from one machine to other machine(By passing the command line arguments like server name, user name ,location of the files, file names etc) but when i am using sftp, what are the things I have to specify in the code Is it necessary to specify... (0 Replies)
Discussion started by: gsri
0 Replies
Login or Register to Ask a Question