0

I have about 20 Macs on my network that always need fonts installed.

I have a folder location where I ask them to put the fonts they need synced to every machine (as to save time i will install the font on every machine so that if they move machines, i don't need to do it again)

at the moment I am just manually rsyncing the fonts from this server location to all the machines one by one using

rsync -avrP /server/fonts/ /Library/Fonts/  

this requires me to ssh into every machine

is there a way i can script this using a hosts.txt file with the ips? the password is the same for every machine and i'd rather not type it 20 times. Security isn't an issue.

something that allows me to call the script and point it at a font i.e.

./install-font font.ttf

I've looked into scp but I don't see any example of specifying a password anywhere in the script.

cscp.sh

#!/bin/bash
while read host; do
  scp $1 ${host}:
done


project-prod-web1
project-prod-web2
project-prod-web3

Usage

Copy file to multiple hosts:

cscp.sh file < hosts

But this asks me to type a password every time and doesn't specify the target location on the host.

Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271
davidlumix
  • 101
  • 1
  • Is [this](https://stackoverflow.com/questions/32255660/how-to-install-sshpass-on-mac) answer your question? – Ivan Jan 23 '20 at 14:52

1 Answers1

1

I don't see any example of specifying a password anywhere in the script.

Use ssh-copy-id command to install your public key to each of these hosts. After that ssh and scp will use public-private key authentication without requiring you to enter the password.

Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271
  • where would that go in the script? – davidlumix Jan 23 '20 at 11:00
  • If there is an askpass that retain the key unlocked during session or a key without password (witch is a very bad idea). @davidlumix the `ssh-copy-id` is used once for each host. – Léa Gris Jan 23 '20 at 11:02
  • @davidlumix You run `ssh-copy-id` once per each host outside of any script. I recommend reading the article I linked for you, it contains all the information you need to get this issue sorted. – Maxim Egorushkin Jan 23 '20 at 11:17