- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: SFTP script
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
Forums
Discussions
Discussions
Discussions
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
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
09-06-2004 08:38 PM
09-06-2004 08:38 PM
Pls help. I am running the following script to transfer file using sftp. Everytime the script running, it's always prompting a password. It looks like the script ignores stdin.
Is there anyway to prevent from prompting a password wihthout generate public/private keys.
Pls help. High score will be given.
Thanks an Best Regards,
Negara
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2004 08:39 PM
09-06-2004 08:39 PM
Re: SFTP script
sftp ap1030@sihp8024 <<-EOF
get test_file
bye
EOF
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2004 09:02 PM
09-06-2004 09:02 PM
Re: SFTP script
Did you make the setup of interactive sftp or not. We can not include the passwd of sftp in the command line without setting the ssh* on interactive setup.
openssh 3.9 version is supporing rhosts with out any key after compromising the security and some setup issues there.
Best way on this is to use RhostsRSAauthentication method for sftp.
You are going to create one host key and put that key in the remote hosts known_hosts file with hostname.
If you want to come out from sftp then use ftp easily as,
ftp -i hostname -n <<-EOF 2>/dev/null
open username passwd
ls
bye
EOF
Without making interactive setup for s* commands we can not expect your requirement completion.
And Refer this to setup s* commands not to look passwd with RhostsRASauthenticaiton as,
http://www.akadia.com/services/ssh_scp_without_password.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2004 09:11 PM
09-06-2004 09:11 PM
SolutionTry the following,
The following script will spawn sftp in batch mode. The password prompt will be taken care by the expect.
#!/usr/local/bin/expect
spawn sftp -b batchFile ap1030@sihp8024
expect "password:"
send "
interact
your batchFile may contain
get test_file
bye
A one step level of security can be encrypting your expect script using gnupg so that your password will be concealed
http://www.gnupg.org/
For more information on expect scripts
http://expect.nist.gov/
A example of automating sftp using expect can be seen at the following link
http://linux-bsd-central.com/index.php/content/view/26/29/
All the best
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2004 10:09 PM
09-06-2004 10:09 PM
Re: SFTP script
I have tried already, but it didn't work. Is it because my version is 3.7?
[root@sihp8012:/home/ap1030/aldo]
# ssh -V
OpenSSH_3.7.1p2, SSH protocols 1.5/2.0, OpenSSL 0.9.7c 30 Sep 2003
Hi Michael,
Thanks alot for your help. The script is running well. I am considering to use the script, but I will try to find out how to encrypt expect script. Do you have the example how to do that, since I still can not find the link that you sent me.
Thanks alot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2004 11:45 PM
09-06-2004 11:45 PM
Re: SFTP script
Nice to hear that your problem got solved.
Regarding gnupg, It is an opensouce encryption tool based on PGP ( Pretty Good Privacy ). It is a public-key encryption application.
You can get the source from http://www.gnupg.org
Here it is in action:
$ gpg -e
Once this is done a file called 'my_secret_file.txt.gpg' is created in your current directory. Any attempts to view the contents of this file will prove futile unless you encrypted it using your own Public Key.
To decrypt it you simply use the -d switch followed by the encrypted file.
$ gpg -d secret_file.txt.gpg
Since you have your private key contained within your secret key ring GnuPG can determine whom 'secret_file.txt.gpg' was intended for and will decrypt it after you provide your passphrase.
For more information refer the following link
http://www.technocage.com/~caskey/gnupg/pgp2gnupg.html
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2004 01:04 PM
09-07-2004 01:04 PM
Re: SFTP script
Use "ssh-keygen -t dsa" to generate the files $HOME/.ssh/id_dsa and $HOME/.ssh/id_dsa.pub. Don't give it a passphrase (the script looks like it's going to be run unattended).
Append the contents of id_dsa.pub to $HOME/.ssh/authorized_keys on the remote host.
This will allow you to log on to ssh, scp and scp using public key authentication when you either specify the identity file (id_dsa), or when that file is in the current user's configured $HOME directory.
Your script could change to:
sftp ap1030@sihp8024 <<-EOF
get test_file
bye
EOF
or the equivalent:
sftp ap1030@sihp8024:test_file
I'd love to hear comments on this!
Regards,
Seth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2004 02:14 PM
09-07-2004 02:14 PM
Re: SFTP script
I'm attaching instructions. They refer to X, you can do it with careful cat commands. Pay attention to directory permissions.
Word doc.
Its in this thead. I can't find a copy here right now.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=144612
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
09-07-2004 05:10 PM
09-07-2004 05:10 PM
Re: SFTP script
Thanks alot. I tried to install GPG on my test server using configure, make, make install and make clean respectively. But when I tried to run gpg, I got the error as below :
[root@sihp8012:/tmp]
# gpg -e sftp
gpg: failed to create temporary file `/root/.gnupg/.#lk4000d3c0.sihp8012.9344': No such file or directory
gpg: keyblock resource `/root/.gnupg/secring.gpg': general error
gpg: failed to create temporary file `/root/.gnupg/.#lk4000d3c0.sihp8012.9344': No such file or directory
gpg: keyblock resource `/root/.gnupg/pubring.gpg': general error
You did not specify a user ID. (you may use "-r")
Enter the user ID. End with an empty line: 123456CA
No such user ID.
Enter the user ID. End with an empty line: ap1030
No such user ID.
Enter the user ID. End with an empty line:
gpg: no valid addressees
gpg: sftp: encryption failed: no such user id
[root@sihp8012:/tmp]
# gpg sftp
gpg: failed to create temporary file `/root/.gnupg/.#lk4000d3c0.sihp8012.9345': No such file or directory
gpg: keyblock resource `/root/.gnupg/secring.gpg': general error
gpg: failed to create temporary file `/root/.gnupg/.#lk4000d3c0.sihp8012.9345': No such file or directory
gpg: keyblock resource `/root/.gnupg/pubring.gpg': general error
gpg: no valid OpenPGP data found.
gpg: processing message failed: eof
Any idea what is wrong?
Hi Seth,
Thanks alot for your great contribution. The main reason why we are not considering public/private keys is that the policy for the keys have not been established yet. So this just for temporary solution before using public/private keys.
Hi Steven,
Thanks alot for answer.