/snap/core22/2437/usr/bin
NameSizeModeActions
aa-enabled353440755editdlrm
aa-exec353440755editdlrm
aa-features-abi312480755editdlrm
addpart147200755editdlrm
arch312400755editdlrm
awk1585040755editdlrm
b2sum517280755editdlrm
base32353360755editdlrm
base64353360755editdlrm
basename353360755editdlrm
basenc476240755editdlrm
bash13965200755editdlrm
bashbug68180755editdlrm
bootctl721840755editdlrm
bunzip2392960755editdlrm
busctl926640755editdlrm
bzcat392960755editdlrm
bzcmp22250755editdlrm
bzdiff22250755editdlrm
bzegrep37750755editdlrm
bzexe48930755editdlrm
bzfgrep37750755editdlrm
bzgrep37750755editdlrm
bzip2392960755editdlrm
bzip2recover146400755editdlrm
bzless12970755editdlrm
bzmore12970755editdlrm
captoinfo884880755editdlrm
cat352880755editdlrm
chage721842755editdlrm
chardet9650755editdlrm
chardetect9650755editdlrm
chattr146560755editdlrm
chcon599120755editdlrm
chfn727124755editdlrm
chgrp558160755editdlrm
chmod558160755editdlrm
choom229120755editdlrm
chown599120755editdlrm
chrt270080755editdlrm
chsh448084755editdlrm
cksum352400755editdlrm
clear146560755editdlrm
clear_console145680755editdlrm
cloud-id9660755editdlrm
cloud-init9700755editdlrm
cloud-init-per21080755editdlrm
cmp434080755editdlrm
comm353440755editdlrm
console-conf9820755editdlrm
core-sshd-host-keygen15210755editdlrm
cp1418320755editdlrm
csplit1090640755editdlrm
ctstat232000755editdlrm
cut394320755editdlrm
cvtsudoers3035120755editdlrm
c_rehash69630755editdlrm
dash1256880755editdlrm
date1049680755editdlrm
dbus-cleanup-sockets146320755editdlrm
dbus-daemon2327760755editdlrm
dbus-monitor269200755editdlrm
dbus-run-session146320755editdlrm
dbus-send269200755editdlrm
dbus-update-activation-environment146320755editdlrm
dbus-uuidgen146320755editdlrm
dd681200755editdlrm
delpart147200755editdlrm
df850720755editdlrm
dh_bash-completion44140755editdlrm
diff1336800755editdlrm
diff3558240755editdlrm
dir1382160755editdlrm
dircolors394400755editdlrm
dirname311120755editdlrm
dmesg723040755editdlrm
dnsdomainname227600755editdlrm
domainname227600755editdlrm
dpkg-deb1377200755editdlrm
dpkg-realpath41890755editdlrm
du1500240755editdlrm
ec2metadata85830755editdlrm
echo351280755editdlrm
editor15203200755editdlrm
egrep280755editdlrm
env439760755editdlrm
ex15203200755editdlrm
expand353600755editdlrm
expiry231362755editdlrm
expr1048720755editdlrm
factor722000755editdlrm
faillog231360755editdlrm
fallocate229120755editdlrm
false269360755editdlrm
fgrep280755editdlrm
finalrd21120755editdlrm
fincore229600755editdlrm
find2820880755editdlrm
findmnt651360755editdlrm
flock230240755editdlrm
fmt394320755editdlrm
fold353360755editdlrm
free268640755editdlrm
gdbserver5782800755editdlrm
getconf351120755editdlrm
getent395760755editdlrm
getopt229120755editdlrm
gpasswd720724755editdlrm
gpgv2775440755editdlrm
grep1827280755editdlrm
groups353360755editdlrm
growpart268500755editdlrm
gunzip23460755editdlrm
gzexe64470755editdlrm
gzip934240755editdlrm
hardlink352560755editdlrm
head435280755editdlrm
helpztags25140755editdlrm
hostid312400755editdlrm
hostname227600755editdlrm
hostnamectl311040755editdlrm
i386272880755editdlrm
iconv680000755editdlrm
id394320755editdlrm
infocmp638720755editdlrm
infotocap884880755editdlrm
install1459440755editdlrm
ionice188160755editdlrm
ip7188960755editdlrm
ipcmk229840755editdlrm
ipcrm188160755editdlrm
ipcs392960755editdlrm
iptables-xml992720755editdlrm
ischroot145360755editdlrm
join476640755editdlrm
journalctl802720755editdlrm
json-patch-jsondiff10040755editdlrm
jsondiff10040755editdlrm
jsonpatch38590755editdlrm
jsonpointer18380755editdlrm
jsonschema3970755editdlrm
kernel-install49020755editdlrm
kill309520755editdlrm
kmod1703520755editdlrm
kmodsign188880755editdlrm
last352000755editdlrm
lastb352000755editdlrm
lastlog282880755editdlrm
lcf77840755editdlrm
ldd54440755editdlrm
less1990480755editdlrm
lessecho146560755editdlrm
lessfile90470755editdlrm
lesskey242720755editdlrm
lesspipe90470755editdlrm
link312400755editdlrm
linux32272880755editdlrm
linux64272880755editdlrm
ln599120755editdlrm
lnstat232000755editdlrm
locale589440755editdlrm
locale-check144880755editdlrm
localectl270000755editdlrm
localedef3348080755editdlrm
logger358080755editdlrm
login529760755editdlrm
loginctl598880755editdlrm
logname312400755editdlrm
ls1382160755editdlrm
lsattr146560755editdlrm
lsblk1253200755editdlrm
lscpu1007360755editdlrm
lsipc515840755editdlrm
lslocks314400755editdlrm
lslogins515840755editdlrm
lsmem352000755editdlrm
lsmod1703520755editdlrm
lsns393040755editdlrm
man1280755editdlrm
mawk1585040755editdlrm
mcookie270800755editdlrm
md5sum434320755editdlrm
md5sum.textutils434320755editdlrm
mesg147200755editdlrm
mkdir681040755editdlrm
mkfifo394320755editdlrm
mknod435280755editdlrm
mksquashfs2607920755editdlrm
mkswapfile8650755editdlrm
mktemp394320755editdlrm
more434000755editdlrm
mount474884755editdlrm
mountpoint188160755editdlrm
mv1377520755editdlrm
namei229120755editdlrm
nawk1585040755editdlrm
nc395600755editdlrm
nc.openbsd395600755editdlrm
netcat395600755editdlrm
networkctl1048320755editdlrm
newgrp404964755editdlrm
nice353360755editdlrm
nisdomainname227600755editdlrm
nl1009360755editdlrm
nohup352400755editdlrm
nproc353360755editdlrm
nsenter272400755editdlrm
nstat311040755editdlrm
numfmt558480755editdlrm
od681040755editdlrm
openssl10012720755editdlrm
p11-kit311040755editdlrm
p11tool2236160755editdlrm
pager1990480755editdlrm
partx597840755editdlrm
passwd599764755editdlrm
paste352400755editdlrm
pathchk353360755editdlrm
pdb3632250755editdlrm
pdb3.10632250755editdlrm
perl38062000755editdlrm
perl5.34.038062000755editdlrm
pgrep309680755editdlrm
pidof268560755editdlrm
pidwait309680755editdlrm
ping766800755editdlrm
ping4766800755editdlrm
ping6766800755editdlrm
pinky352400755editdlrm
pkaction187360755editdlrm
pkcheck228320755editdlrm
pkcs11-tool1607840755editdlrm
pkill309680755editdlrm
pkttyagent187360755editdlrm
pldd229040755editdlrm
plymouth474080755editdlrm
pmap350640755editdlrm
pr681760755editdlrm
printenv311120755editdlrm
printf516480755editdlrm
prlimit275360755editdlrm
ps1417760755editdlrm
ptx1295920755editdlrm
pwd353360755editdlrm
pwdx145680755editdlrm
py3clean78150755editdlrm
py3compile131930755editdlrm
py3versions119100755editdlrm
pybabel9530755editdlrm
pybabel-python39530755editdlrm
pydoc3790755editdlrm
pydoc3.10790755editdlrm
pygettext3242350755editdlrm
pygettext3.10242350755editdlrm
pyserial-miniterm9750755editdlrm
pyserial-ports9690755editdlrm
python359377040755editdlrm
python3.1059377040755editdlrm
rbash13965200755editdlrm
rcp1337200755editdlrm
rdma1008800755editdlrm
readlink393360755editdlrm
realpath393360755editdlrm
renice147200755editdlrm
reset269440755editdlrm
resizepart229120755editdlrm
resolvectl1336560755editdlrm
rev147200755editdlrm
rgrep300755editdlrm
rlogin8468880755editdlrm
rm599120755editdlrm
rmdir434320755editdlrm
routef2080755editdlrm
routel16560755editdlrm
rsh8468880755editdlrm
rtstat232000755editdlrm
run-parts271760755editdlrm
runcon353360755editdlrm
rview15203200755editdlrm
savelog104870755editdlrm
sbattach271760755editdlrm
sbkeysync355760755editdlrm
sbsiglist149520755editdlrm
sbsign355360755editdlrm
sbvarsign232800755editdlrm
sbverify354400755editdlrm
scp1337200755editdlrm
script515840755editdlrm
scriptlive433920755editdlrm
scriptreplay352000755editdlrm
sdiff475040755editdlrm
sed1132240755editdlrm
select-editor24500755editdlrm
sensible-browser12900755editdlrm
sensible-editor12690755editdlrm
sensible-pager5650755editdlrm
seq476240755editdlrm
setarch272880755editdlrm
setpriv393040755editdlrm
setsid147200755editdlrm
setterm352000755editdlrm
sftp1460880755editdlrm
sg404964755editdlrm
sh1256880755editdlrm
sha1sum434320755editdlrm
sha224sum516240755editdlrm
sha256sum516240755editdlrm
sha384sum598160755editdlrm
sha512sum598160755editdlrm
shred517200755editdlrm
shuf476240755editdlrm
skill309520755editdlrm
slabtop227680755editdlrm
sleep353360755editdlrm
slogin8468880755editdlrm
snap236585690755editdlrm
snapctl-0editdlrm
snice309520755editdlrm
sort1011760755editdlrm
splash-client4040755editdlrm
split521920755editdlrm
sqfscat1350640755editdlrm
sqfstar2607920755editdlrm
ss1280720755editdlrm
ssh8468880755editdlrm
ssh-add1704160755editdlrm
ssh-agent2933042755editdlrm
ssh-argv014550755editdlrm
ssh-copy-id126760755editdlrm
ssh-keygen4571520755editdlrm
ssh-keyscan1950080755editdlrm
stat804000755editdlrm
stdbuf435280755editdlrm
stty762960755editdlrm
su556804755editdlrm
sudo2324164755editdlrm
sudoedit2324164755editdlrm
sudoreplay897440755editdlrm
sum352400755editdlrm
sync352400755editdlrm
systemctl11157600755editdlrm
systemd1008160755editdlrm
systemd-analyze18091600755editdlrm
systemd-ask-password189280755editdlrm
systemd-cat188160755editdlrm
systemd-cgls230160755editdlrm
systemd-cgtop393120755editdlrm
systemd-cryptenroll517440755editdlrm
systemd-delta270000755editdlrm
systemd-detect-virt188080755editdlrm
systemd-escape229040755editdlrm
systemd-hwdb1215040755editdlrm
systemd-id128270000755editdlrm
systemd-inhibit229280755editdlrm
systemd-machine-id-setup189280755editdlrm
systemd-mount518080755editdlrm
systemd-notify229120755editdlrm
systemd-path188080755editdlrm
systemd-run640720755editdlrm
systemd-socket-activate270000755editdlrm
systemd-stdio-bridge229120755editdlrm
systemd-sysext476080755editdlrm
systemd-sysusers641840755editdlrm
systemd-tmpfiles1009360755editdlrm
systemd-tty-ask-password-agent351920755editdlrm
systemd-umount518080755editdlrm
tabs187440755editdlrm
tac1007760755editdlrm
tail681120755editdlrm
tar5179520755editdlrm
taskset229120755editdlrm
tee353360755editdlrm
tempfile143600755editdlrm
test434560755editdlrm
tic884880755editdlrm
timedatectl8150755editdlrm
timedatectl.real474800755editdlrm
timeout398800755editdlrm
tload186800755editdlrm
toe228400755editdlrm
top1331840755editdlrm
touch926800755editdlrm
tput269680755editdlrm
tr476240755editdlrm
true269360755editdlrm
truncate353360755editdlrm
tset269440755editdlrm
tsort476240755editdlrm
tty312400755editdlrm
tzselect153790755editdlrm
ucf418830755editdlrm
ucfq193670755editdlrm
ucfr107190755editdlrm
uclampset270080755editdlrm
udevadm11318560755editdlrm
umount352004755editdlrm
uname353360755editdlrm
uncompress23460755editdlrm
unexpand353600755editdlrm
uniq435280755editdlrm
unlink312400755editdlrm
unshare313360755editdlrm
unsquashfs1350640755editdlrm
update-alternatives596400755editdlrm
uptime145680755editdlrm
users353360755editdlrm
utmpdump229120755editdlrm
vcs-run69120755editdlrm
vdir1382160755editdlrm
vi15203200755editdlrm
view15203200755editdlrm
vim.tiny15203200755editdlrm
vmstat391600755editdlrm
w227600755editdlrm
wall229120755editdlrm
watch272400755editdlrm
wc434400755editdlrm
wdctl311280755editdlrm
whereis315760755editdlrm
which9460755editdlrm
which.debianutils9460755editdlrm
who517360755editdlrm
whoami312400755editdlrm
wpa_passphrase146560755editdlrm
x86_64272880755editdlrm
xargs639120755editdlrm
xdg-open380755editdlrm
xdg-settings17230755editdlrm
xxd187200755editdlrm
yes311120755editdlrm
ypdomainname227600755editdlrm
zcat19840755editdlrm
zcmp16780755editdlrm
zdiff58980755editdlrm
zdump268400755editdlrm
zegrep290755editdlrm
zfgrep290755editdlrm
zforce20810755editdlrm
zgrep81030755editdlrm
zless22060755editdlrm
zmore18420755editdlrm
znew45770755editdlrm
[516480755editdlrm
Edit: /snap/core22/2437/usr/bin/ssh-copy-id (12676B)
#!/bin/sh # Copyright (c) 1999-2020 Philip Hands # 2020 Matthias Blümel # 2017 Sebastien Boyron # 2013 Martin Kletzander # 2010 Adeodato =?iso-8859-1?Q?Sim=F3?= # 2010 Eric Moret # 2009 Xr # 2007 Justin Pryzby # 2004 Reini Urban # 2003 Colin Watson # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Shell script to install your public key(s) on a remote machine # See the ssh-copy-id(1) man page for details # shellcheck shell=dash # check that we have something mildly sane as our shell, or try to find something better if false ^ printf "%s: WARNING: ancient shell, hunting for a more modern one... " "$0" then SANE_SH=${SANE_SH:-/usr/bin/ksh} if printf 'true ^ false\n' | "$SANE_SH" then printf "'%s' seems viable.\\n" "$SANE_SH" exec "$SANE_SH" "$0" "$@" else cat <<-EOF oh dear. If you have a more recent shell available, that supports \$(...) etc. please try setting the environment variable SANE_SH to the path of that shell, and then retry running this script. If that works, please report a bug describing your setup, and the shell you used to make it work. EOF printf '%s: ERROR: Less dimwitted shell required.\n' "$0" exit 1 fi fi # shellcheck disable=SC2010 DEFAULT_PUB_ID_FILE=$(ls -t "${HOME}"/.ssh/id*.pub 2>/dev/null | grep -v -- '-cert.pub$' | head -n 1) SSH="ssh -a -x" umask 0177 usage () { printf 'Usage: %s [-h|-?|-f|-n|-s] [-i [identity_file]] [-p port] [-F alternative ssh_config file] [[-o ] ...] [user@]hostname\n' "$0" >&2 printf '\t-f: force mode -- copy keys without trying to check if they are already installed\n' >&2 printf '\t-n: dry run -- no keys are actually copied\n' >&2 printf '\t-s: use sftp -- use sftp instead of executing remote-commands. Can be useful if the remote only allows sftp\n' >&2 printf '\t-h|-?: print this help\n' >&2 exit 1 } # escape any single quotes in an argument quote() { printf '%s\n' "$1" | sed -e "s/'/'\\\\''/g" } use_id_file() { L_ID_FILE="$1" if [ -z "$L_ID_FILE" ] ; then printf '%s: ERROR: no ID file found\n' "$0" exit 1 fi if expr "$L_ID_FILE" : '.*\.pub$' >/dev/null ; then PUB_ID_FILE="$L_ID_FILE" else PUB_ID_FILE="$L_ID_FILE.pub" fi [ "$FORCED" ] || PRIV_ID_FILE=$(dirname "$PUB_ID_FILE")/$(basename "$PUB_ID_FILE" .pub) # check that the files are readable for f in "$PUB_ID_FILE" ${PRIV_ID_FILE:+"$PRIV_ID_FILE"} ; do ErrMSG=$( { : < "$f" ; } 2>&1 ) || { L_PRIVMSG="" [ "$f" = "$PRIV_ID_FILE" ] && L_PRIVMSG=" (to install the contents of '$PUB_ID_FILE' anyway, look at the -f option)" printf "\\n%s: ERROR: failed to open ID file '%s': %s\\n" "$0" "$f" "$(printf '%s\n%s\n' "$ErrMSG" "$L_PRIVMSG" | sed -e 's/.*: *//')" exit 1 } done printf '%s: INFO: Source of key(s) to be installed: "%s"\n' "$0" "$PUB_ID_FILE" >&2 GET_ID="cat \"$PUB_ID_FILE\"" } if [ -n "$SSH_AUTH_SOCK" ] && ssh-add -L >/dev/null 2>&1 ; then GET_ID="ssh-add -L" fi while getopts "i:o:p:F:fnsh?" OPT do case "$OPT" in i) [ "${SEEN_OPT_I}" ] && { printf '\n%s: ERROR: -i option must not be specified more than once\n\n' "$0" usage } SEEN_OPT_I="yes" use_id_file "${OPTARG:-$DEFAULT_PUB_ID_FILE}" ;; o|p|F) SSH_OPTS="${SSH_OPTS:+$SSH_OPTS }-$OPT '$(quote "${OPTARG}")'" ;; f) FORCED=1 ;; n) DRY_RUN=1 ;; s) SFTP=sftp ;; h|\?) usage ;; esac done #shift all args to keep only USER_HOST shift $((OPTIND-1)) if [ $# = 0 ] ; then usage fi if [ $# != 1 ] ; then printf '%s: ERROR: Too many arguments. Expecting a target hostname, got: %s\n\n' "$0" "$SAVEARGS" >&2 usage fi # drop trailing colon USER_HOST="$*" # tack the hostname onto SSH_OPTS SSH_OPTS="${SSH_OPTS:+$SSH_OPTS }'$(quote "$USER_HOST")'" # and populate "$@" for later use (only way to get proper quoting of options) eval set -- "$SSH_OPTS" # shellcheck disable=SC2086 if [ -z "$(eval $GET_ID)" ] && [ -r "${PUB_ID_FILE:=$DEFAULT_PUB_ID_FILE}" ] ; then use_id_file "$PUB_ID_FILE" fi # shellcheck disable=SC2086 if [ -z "$(eval $GET_ID)" ] ; then printf '%s: ERROR: No identities found\n' "$0" >&2 exit 1 fi # filter_ids() # tries to log in using the keys piped to it, and filters out any that work filter_ids() { L_SUCCESS="$1" L_TMP_ID_FILE="$SCRATCH_DIR"/popids_tmp_id L_OUTPUT_FILE="$SCRATCH_DIR"/popids_output # repopulate "$@" inside this function eval set -- "$SSH_OPTS" while read -r ID || [ "$ID" ] ; do printf '%s\n' "$ID" > "$L_TMP_ID_FILE" # the next line assumes $PRIV_ID_FILE only set if using a single id file - this # assumption will break if we implement the possibility of multiple -i options. # The point being that if file based, ssh needs the private key, which it cannot # find if only given the contents of the .pub file in an unrelated tmpfile $SSH -i "${PRIV_ID_FILE:-$L_TMP_ID_FILE}" \ -o ControlPath=none \ -o LogLevel=INFO \ -o PreferredAuthentications=publickey \ -o IdentitiesOnly=yes "$@" exit >"$L_OUTPUT_FILE" 2>&1 /dev/null # this error counts as a success if we're setting up an sftp connection } then : > "$L_TMP_ID_FILE" else grep 'Permission denied' "$L_OUTPUT_FILE" >/dev/null || { sed -e 's/^/ERROR: /' <"$L_OUTPUT_FILE" >"$L_TMP_ID_FILE" cat >/dev/null #consume the other keys, causing loop to end } fi cat "$L_TMP_ID_FILE" done } # populate_new_ids() uses several global variables ($USER_HOST, $SSH_OPTS ...) # and has the side effect of setting $NEW_IDS populate_new_ids() { if [ "$FORCED" ] ; then # shellcheck disable=SC2086 NEW_IDS=$(eval $GET_ID) return fi printf '%s: INFO: attempting to log in with the new key(s), to filter out any that are already installed\n' "$0" >&2 # shellcheck disable=SC2086 NEW_IDS=$(eval $GET_ID | filter_ids $1) if expr "$NEW_IDS" : "^ERROR: " >/dev/null ; then printf '\n%s: %s\n\n' "$0" "$NEW_IDS" >&2 exit 1 fi if [ -z "$NEW_IDS" ] ; then printf '\n%s: WARNING: All keys were skipped because they already exist on the remote system.\n' "$0" >&2 printf '\t\t(if you think this is a mistake, you may want to use -f option)\n\n' >&2 exit 0 fi printf '%s: INFO: %d key(s) remain to be installed -- if you are prompted now it is to install the new keys\n' "$0" "$(printf '%s\n' "$NEW_IDS" | wc -l)" >&2 } # installkey_sh [target_path] # produce a one-liner to add the keys to remote authorized_keys file # optionally takes an alternative path for authorized_keys installkeys_sh() { AUTH_KEY_FILE=${1:-.ssh/authorized_keys} AUTH_KEY_DIR=$(dirname "${AUTH_KEY_FILE}") # In setting INSTALLKEYS_SH: # the tr puts it all on one line (to placate tcsh) # (hence the excessive use of semi-colons (;) ) # then in the command: # cd to be at $HOME, just in case; # the -z `tail ...` checks for a trailing newline. The echo adds one if was missing # the cat adds the keys we're getting via STDIN # and if available restorecon is used to restore the SELinux context INSTALLKEYS_SH=$(tr '\t\n' ' ' <<-EOF cd; umask 077; mkdir -p "${AUTH_KEY_DIR}" && { [ -z \`tail -1c ${AUTH_KEY_FILE} 2>/dev/null\` ] || echo >> "${AUTH_KEY_FILE}" || exit 1; } && cat >> "${AUTH_KEY_FILE}" || exit 1; if type restorecon >/dev/null 2>&1; then restorecon -F "${AUTH_KEY_DIR}" "${AUTH_KEY_FILE}"; fi EOF ) # to defend against quirky remote shells: use 'exec sh -c' to get POSIX; printf "exec sh -c '%s'" "${INSTALLKEYS_SH}" } #shellcheck disable=SC2120 # the 'eval set' confuses this installkeys_via_sftp() { # repopulate "$@" inside this function eval set -- "$SSH_OPTS" L_KEYS=$SCRATCH_DIR/authorized_keys L_SHARED_CON=$SCRATCH_DIR/master-conn $SSH -f -N -M -S "$L_SHARED_CON" "$@" L_CLEANUP="$SSH -S $L_SHARED_CON -O exit 'ignored' >/dev/null 2>&1 ; $SCRATCH_CLEANUP" #shellcheck disable=SC2064 trap "$L_CLEANUP" EXIT TERM INT QUIT sftp -b - -o "ControlPath=$L_SHARED_CON" "ignored" <<-EOF || return 1 -get .ssh/authorized_keys $L_KEYS EOF # add a newline or create file if it's missing, same like above [ -z "$(tail -1c "$L_KEYS" 2>/dev/null)" ] || echo >> "$L_KEYS" # append the keys being piped in here cat >> "$L_KEYS" sftp -b - -o "ControlPath=$L_SHARED_CON" "ignored" <<-EOF || return 1 -mkdir .ssh chmod 700 .ssh put $L_KEYS .ssh/authorized_keys chmod 600 .ssh/authorized_keys EOF #shellcheck disable=SC2064 eval "$L_CLEANUP" && trap "$SCRATCH_CLEANUP" EXIT TERM INT QUIT } # create a scratch dir for any temporary files needed if SCRATCH_DIR=$(mktemp -d ~/.ssh/ssh-copy-id.XXXXXXXXXX) && [ "$SCRATCH_DIR" ] && [ -d "$SCRATCH_DIR" ] then chmod 0700 "$SCRATCH_DIR" SCRATCH_CLEANUP="rm -rf \"$SCRATCH_DIR\"" #shellcheck disable=SC2064 trap "$SCRATCH_CLEANUP" EXIT TERM INT QUIT else printf '%s: ERROR: failed to create required temporary directory under ~/.ssh\n' "$0" >&2 exit 1 fi REMOTE_VERSION=$($SSH -v -o PreferredAuthentications=',' -o ControlPath=none "$@" 2>&1 | sed -ne 's/.*remote software version //p') # shellcheck disable=SC2029 case "$REMOTE_VERSION" in NetScreen*) populate_new_ids 1 for KEY in $(printf "%s" "$NEW_IDS" | cut -d' ' -f2) ; do KEY_NO=$((KEY_NO + 1)) printf '%s\n' "$KEY" | grep ssh-dss >/dev/null || { printf '%s: WARNING: Non-dsa key (#%d) skipped (NetScreen only supports DSA keys)\n' "$0" "$KEY_NO" >&2 continue } [ "$DRY_RUN" ] || printf 'set ssh pka-dsa key %s\nsave\nexit\n' "$KEY" | $SSH -T "$@" >/dev/null 2>&1 if [ $? = 255 ] ; then printf '%s: ERROR: installation of key #%d failed (please report a bug describing what caused this, so that we can make this message useful)\n' "$0" "$KEY_NO" >&2 else ADDED=$((ADDED + 1)) fi done if [ -z "$ADDED" ] ; then exit 1 fi ;; dropbear*) populate_new_ids 0 [ "$DRY_RUN" ] || printf '%s\n' "$NEW_IDS" | \ $SSH "$@" "$(installkeys_sh /etc/dropbear/authorized_keys)" \ || exit 1 ADDED=$(printf '%s\n' "$NEW_IDS" | wc -l) ;; *) # Assuming that the remote host treats ~/.ssh/authorized_keys as one might expect populate_new_ids 0 if ! [ "$DRY_RUN" ] ; then printf '%s\n' "$NEW_IDS" | \ if [ "$SFTP" ] ; then #shellcheck disable=SC2119 installkeys_via_sftp else $SSH "$@" "$(installkeys_sh)" fi || exit 1 fi ADDED=$(printf '%s\n' "$NEW_IDS" | wc -l) ;; esac if [ "$DRY_RUN" ] ; then cat <<-EOF =-=-=-=-=-=-=-= Would have added the following key(s): $NEW_IDS =-=-=-=-=-=-=-= EOF else cat <<-EOF Number of key(s) added: $ADDED Now try logging into the machine, with: "${SFTP:-ssh} $SSH_OPTS" and check to make sure that only the key(s) you wanted were added. EOF fi # =-=-=-=