31 lines
765 B
Bash
31 lines
765 B
Bash
#!/bin/bash
|
|
|
|
sshd_dns () {
|
|
local dir
|
|
local dnsconf
|
|
local conf
|
|
dir=${1:-"/etc/ssh/sshd_config.d"}
|
|
pushd "$dir" 1>/dev/null || return;
|
|
for dnsconf in *.conf.dns; do
|
|
[[ -f "$dnsconf" ]] || break
|
|
conf=$(basename $dnsconf .dns)
|
|
echo "----- processing sshd file $dnsconf to $conf ----"
|
|
sudo cp $dnsconf $conf
|
|
cat $conf
|
|
echo -e "\n------------"
|
|
for host in $(sed -e 's/[ ,]/\n/g' $conf | sed -n 's/[Dd][Nn][Ss]://p'); do
|
|
echo found host $host, substituting $(dig +short $host)
|
|
sudo sed -i 's/[Dd][Nn][Ss]:'$host'/'$(dig +short $host)'/g' $conf
|
|
done
|
|
echo "----- created sshd conf file $conf ----"
|
|
cat $conf
|
|
echo -e "\n------------"
|
|
done
|
|
echo restart ssh service daemon to enable these changes
|
|
popd 1>/dev/null || return
|
|
|
|
}
|
|
|
|
|
|
|