43 lines
1.4 KiB
Bash
43 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
SSH_PUB_KEYS=${SSH_PUB_KEYS:-$HOME/.ssh}
|
|
export SSH_PUB_KEYS
|
|
|
|
sshcp () {
|
|
echo args: $@
|
|
# todo add a use password only flag
|
|
# local opts="-o PreferredAuthentications=password -o PubkeyAuthentication=no"
|
|
local dir=""
|
|
echo options $opts
|
|
[[ $1 = "-u" ]] && user=$2 && shift 2 || user=ubuntu
|
|
local host=$1
|
|
[[ ! $(host_reachable $host) ]] && echo host $host not reachable, aborting mount && return 1
|
|
local src=${2:-$(pwd)}
|
|
echo source: $src
|
|
[[ -d $src ]] && dir="-r"
|
|
echo scp $opts $dir "$src" $user@$host:$3
|
|
scp $opts $dir "$src" $user@$host:$3
|
|
}
|
|
|
|
sshcpid () {
|
|
local opts="-o PreferredAuthentications=password -o PubkeyAuthentication=no"
|
|
local PUB_KEY=${SSH_PUB_KEYS:-$HOME/.ssh}/$3.pub
|
|
[[ $1 = "-u" ]] && user=$2 && shift 2 || user=ubuntu
|
|
dr="-n"
|
|
[[ $4 = "yes" ]] && dr="" || echo add "yes" as last argment to invoke
|
|
ssh-copy-id $opts $dr -f -i $PUB_KEY $1@$2
|
|
}
|
|
|
|
|
|
sshd_disable_pw () {
|
|
module_load config_edit
|
|
local cnf=$(declare -f confirm)
|
|
local cc=$(declare -f config_change)
|
|
declare -A settings
|
|
local settings=( ["PasswordAuthentication"]=no ["PubkeyAuthentication"]=yes ["ChallengeResponseAuthentication"]=no)
|
|
#file=/etc/ssh/sshd_config
|
|
file=test.config
|
|
for setting in ${!settings[@]}; do
|
|
sudo bash -c "$cnf;$cc;config_change $setting ${settings[${setting}]} $file"
|
|
done
|
|
} |