2

I would like to transfer some files from one computer to other 24 macs (which are protected by an user/pass). It is so tedious to do it manually connecting with Finder, transfer the files and continue with the next one...

Is there a way to do it with Terminal (scp or other tool) so that I can just write an script and see how it's automatically done?

Thanks

1 Answer 1

1

It is so tedious to do it manually connecting with Finder, transfer the files and continue with the next one...

Yes it is. There's a GUI solution - Apple Remote Desktop (ARD) was designed with this (as well as much more) in mind.

Is there a way to do it with Terminal (scp or other tool) so that I can just write an script and see how it's automatically done?

Yes there is, but there needs to be some preliminary work done first to make this an automated system.

What you need:

Account with admin privileges and remote login. These are self explanatory. Setting up your SSH keys for a password-less login is detailed in the post "How to SSH in one line"

Using SCP to copy a file, your command could be as simple as:

scp foo.bar admin@computer1:/remote/directory/location/foo.bar

With the SSH keys setup, you won't be prompted for a password.

You could even script this for a batch of computers:

#!/bin/bash
computers=(comp1 comp2 comp3)            #Array of computer names
rdir="/remote/directory/location"        #Remmote directory
file="foo.bar"                           #filename to be xfered
user="admin"                             #login username

for comp in $computers
do
    scp ${user}@${comp}:${rdir}/${file}
done

exit

The script will iterate through the array computers copying the file foo.bar to the remote directory until there are no more items left then exit.

4
  • really amazing answer, thank you very much, it worked like a charm (I have used the scp option, it's free, hehehe. Commented Nov 7, 2017 at 21:57
  • Just one new question: I have tried transferring .app files using "scp -r" and it work but it doesn't show the app icon... any idea? thanks again Commented Nov 7, 2017 at 21:58
  • It most likely because there are no .app files - they are containers (folders). When you install an app, things get installed to multiple locations meaning the icon that goes to the LaunchPad or Dock isn't there anymore. Software should be installed - not copied from another installation.
    – Allan
    Commented Nov 7, 2017 at 22:10
  • Right, but this apps are opensource and have no installer, I mean, they are meant to be just dragged into the /Applications/ folder. I don't know what is misses when copying this .app "special folder". Maybe a workaround is to copy a zipped file with all the apps I want to transfer and then extract the content inside /Applications/ Any other idea? Thanks! Commented Nov 8, 2017 at 9:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .