- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script - SFTP for file transfer
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
тАО07-23-2009 02:27 AM
тАО07-23-2009 02:27 AM
Script - SFTP for file transfer
I want to write a script for file transfer using sftp. I want to automate this script so that at schedule time the script will run and transfer the file. I am already having a script for ftp to transfer the file.
HOST='xxxx.host.com'
USER='abcd'
PASSWD='xxxx'
/usr/bin/ftp -nv $HOST <
mput *.txt
EOF
How can i modify this script for sftp...so that the script can automatically login to there sftp server without asking me for the password. As i have already the password of there sftp server. I am able to connect there sftp server manually.I want to do this task through script.
Thanks,
Narendra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2009 03:29 AM
тАО07-23-2009 03:29 AM
Re: Script - SFTP for file transfer
Main Script
-------------
HOST='xxxx.host.com'
USER='abcd'
PASSWD='xxxx'
sftp -b
Authentication:
---------------
On Local box run 'ssh-keygen -t dsa' to generate private and pub keys copy the public key to remote box in '~user/.ssh/authorized_keys'with cat command
Batchfile:
----------
cd
mput *.txt
Tested OK.
Hope this will help you
Prashant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2009 03:54 AM
тАО07-23-2009 03:54 AM
Re: Script - SFTP for file transfer
As you see sftp works in a pretty similar way to ftp scripting.
The bad part is the script has to have a password hard coded.
There is a better way.
Public Key authentication. Works for ssh,scp,sftp
http://www.hpux.ws/?p=10
The parent site also has a trick for forcing public key authentication only, to stop random script kiddie authentication guessing.
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
тАО07-23-2009 04:07 AM
тАО07-23-2009 04:07 AM
Re: Script - SFTP for file transfer
First you should configure ssh password less login for that user between source and destination server to automate the sftp script.
Once you configured the password less login you can schedule a simple script like this to do the job.
#--------------------------------------------
# Connect to remote server and put the files
#--------------------------------------------
sftp remoteuser@10.0.0.100 <<**
lcd /data/files
put filename.txt
**
#--------------------------------------------
You can also refer this link for how to generate the public key and sftp script.
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1310366
Ganesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2009 04:13 AM
тАО07-23-2009 04:13 AM
Re: Script - SFTP for file transfer
As the user (on your side) that is to connect create your keys to transfer to the other server. Run:
ssh-keygen -t
It will create a private key & a public key (id_rsa.pub for example) under the user the .ssh directory. It will create that directory if it doesn't exist.
Now...take that id_rsa.pub key file and send that over to the other server. If you control this remote server, then just put it in the user on that box account in the .ssh directory.
If it's a box you don't control, contact them to make arrangements to get the file there. I don't recommend email, cause sometimes the file corrupts. Send it ftp
The first time you make the connection you will have to respond "yes", depending on the other side you will likely the first time have to give the password. This updates and accepts the new keys.
From this point on you should be go and not require a password again. Whic means.........no password in your script!
Hope this helps,
Rita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2009 09:34 PM
тАО07-23-2009 09:34 PM
Re: Script - SFTP for file transfer
I know the ssh for password less authenticaition by generating the keys. But what i am looking is i am already having the password for sftp connection to there server. I can manually connect to there server. But i want to do the sftp file transfer through script for automation.
I have searched on google...some-one was reffering for the except, Is anyone have done the scripting for sftp file transfer with except, Please let me know the procedure.
Thanks,
Narendra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2009 11:02 PM
тАО07-23-2009 11:02 PM
Re: Script - SFTP for file transfer
I have installed the 3 software
expect-5.43-hppa-11.11.depot
libXft-2.1.13-hppa-11.11.depot
tcltk-8.5.7-hppa-11.11.depot
and modified the script to use expect for interactive response to answer...
Thanks
Narendra