LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-13-2010, 06:13 AM   #1
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 12.04 / CentOS 6.5
Posts: 394

Rep: Reputation: 61
Automating SFTP in Bash with password?


Hi,

I wrote a script ages ago to automate an FTP transfer. This was easy as within the script you can specify the password with password <whatever>. Now I am wanting to do a similar thing with SFTP (SSH). I know that SFTP works differently and I cannot specify the password within the script - what do I need to do on the server I am connecting to to either "trust" the host I am connecting from or to somehow specify the password for "sftp user@some_host"? It's IP address will always be the same.

Thanks for any advice.
 
Old 07-13-2010, 06:51 AM   #2
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,085

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
sftp uses ssh
see man sftp

So you could set up private/public key-based authentication without a password, and it'll work.

Some howtos:
http://www.linuxhomenetworking.com/w...d_File_Copying
http://sial.org/howto/openssh/publickey-auth/

You could also look at scp
 
Old 07-13-2010, 11:44 AM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,051

Rep: Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852
one other note is that scp is useful for automation whereas sftp is useful when human intervention is necessary for entering prompts.
 
Old 07-14-2010, 04:56 AM   #4
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 12.04 / CentOS 6.5
Posts: 394

Original Poster
Rep: Reputation: 61
I would use SSH public key encryption, but the machine I want to connect from only has a DHCP-assigned IP address and the gateway address (where the connection would appear from) will change periodically. So unless I have a host with a static IP address, I don't seem to be able to use SSH public key encryption. I think I'll have to use AutoExpect/Expect instead, unless anyone has any better ideas.
 
Old 07-14-2010, 08:35 AM   #5
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,051

Rep: Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852
^ maybe dyndns will help ?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[bash script] automating ntfsresize? Naviathan Programming 9 12-05-2012 10:57 AM
Automating sftp using a shell script bhandu Linux - Newbie 3 07-17-2007 02:56 AM
automating scp copy, how to enter password via script? stefaandk Programming 3 11-29-2006 10:57 AM
automating password change remotely noir911 Linux - Security 1 03-23-2006 09:32 AM
Bash Shellscript automating command input JoeneB Programming 3 01-13-2006 02:59 AM


All times are GMT -5. The time now is 05:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration