- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Automating SFTP via Scripting through Cron
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2004 08:38 AM
тАО10-14-2004 08:38 AM
Does anyone have any good documents on how to script the sftp process, or if you could just give me an example of a sftp script where you logged in with a username and password and did a get or a put.
Thanks in advance,
Jason
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2004 08:43 AM
тАО10-14-2004 08:43 AM
Re: Automating SFTP via Scripting through Cron
The ascii binary command needs to be removed
sftp user@hostname >> EOF
password
cd
get *
put *
EOF
This method is insecure.
It hard codes a password to a file. It is not necessary.
sftp comes with a command called scp.
scp works like rcp but its secure. You can exchange public keys(see attached doc) and do transfers as follows:
scp * targethost://directory
Secure, no passwords hardcoded into scripts.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2004 08:44 AM
тАО10-14-2004 08:44 AM
Re: Automating SFTP via Scripting through Cron
You can use the '-b' option with sftp to specify a batchfile of commands for it to use. I would suggest configuring your sftp/ssh so that it doesn't require usernames or passwords (non-interactive authentication), so that you don't have them inside of your batch file.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2004 08:48 AM
тАО10-14-2004 08:48 AM
Re: Automating SFTP via Scripting through Cron
For 'sftp' all you have to do is to setup public/private key authentication. For ex., if you are sftping as user1 on sys1 to user2 on sys2, then do
user1@sys1:ssh-keygen -t dsa -N ""
user1@sys1: ll .ssh/id_dsa.pub
Copy id_dsa.pub file onto sys2 into /tmp dir
user2@sys2: mkdir -p .ssh
user2@sys2:cd .ssh
user2@sys2:cat /tmp/id_dsa.pub >> authorized_Keys
user1@sys1:sftp user2@sys2 << EOF
cd /somewhere
put somefiles\*
quit
EOF
Above shouldn't prompt for a password. If you are going to hardcode username and password, then even sftp will be unsecure though not as bad as ftp.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2004 08:58 AM
тАО10-14-2004 08:58 AM
Re: Automating SFTP via Scripting through Cron
Thanks for all the support so far!
Ja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2004 09:55 AM
тАО10-14-2004 09:55 AM
SolutionWhat I do is to specify only publickey authentication. So, if it fails, it will not go keyboard interactive. For ex.,
sftp -o "PreferredAuthentications publickey"
...
..
EOF
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2004 10:00 AM
тАО10-14-2004 10:00 AM