Re: [OT] SSH login script - Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dan Track wrote:
> Hi Guys,
> 
> I've written a simple for loop see below:
> 
> for i in orion earth;do scp /etc/hosts /etc;done
> 
> I have a small scripting knowledge so would appreciate some help. What
> I'd like to do is somehow change the above so that the script prompts
> me for a password and when I give the script the password it will use
> it to auto-reply to any password promtps that scp asks for when
> logging into all the servers. If I am right I believe readline needs
> to be used. If it can't be done in bash can you give me a perl
> alternative please.
> 
> Thanks for your help.
> 
> Dan
> 
You are not giving scp a host to connect to, so you are in effect
coping /etc/hosts on the local machine to /etc/hosts on the local
machine. Try something like:

for i in orion earth ; do scp /etc/hosts $i:/etc/hosts ; done

I tend to be conservative, and specify the entire file name for the
target. It isn't required in this case, but I like to play it safe.
In order for this to work, you need to have your public key in
/root/.gnupg on the target machines. You have to have the key
unlocked, or not have a pass phrase. The script also has to be run
as root.

If you want to run the script as a normal user, you can use:

for i in orion earth ; do scp /etc/hosts root@$i:/etc/hosts ; done

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux