LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 05:13 AM   #1
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 18.04 / CentOS 7.6
Posts: 397

Rep: Reputation: 62
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, 05:51 AM   #2
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
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, 10:44 AM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
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, 03:56 AM   #4
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 18.04 / CentOS 7.6
Posts: 397

Original Poster
Rep: Reputation: 62
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, 07:35 AM   #5
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

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


Reply



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 09:57 AM
Automating sftp using a shell script bhandu Linux - Newbie 3 07-17-2007 01:56 AM
automating scp copy, how to enter password via script? stefaandk Programming 3 11-29-2006 09:57 AM
automating password change remotely noir911 Linux - Security 1 03-23-2006 08:32 AM
Bash Shellscript automating command input JoeneB Programming 3 01-13-2006 01:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:08 PM.

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
Open Source Consulting | Domain Registration