XYZ File Manager
Current Path:
/usr/bin
usr
/
bin
/
π
..
π
7za
(49 B)
π
[
(51.8 KB)
π
aclocal
(35.52 KB)
π
aclocal-1.16
(35.52 KB)
π
addr2line
(27.74 KB)
π
ar
(55.98 KB)
π
arch
(31.66 KB)
π
arpaname
(15.11 KB)
π
as
(710.31 KB)
π
aspell
(151.12 KB)
π
autoconf
(14.42 KB)
π
autoheader
(8.33 KB)
π
autom4te
(31.43 KB)
π
automake
(251.93 KB)
π
automake-1.16
(251.93 KB)
π
autoreconf
(20.57 KB)
π
autoscan
(16.72 KB)
π
autoupdate
(33.08 KB)
π
awk
(698.17 KB)
π
b2sum
(51.79 KB)
π
base32
(35.69 KB)
π
base64
(35.7 KB)
π
basename
(35.67 KB)
π
basenc
(48.02 KB)
π
bash
(1.32 MB)
π
bashbug-64
(6.91 KB)
π
bunzip2
(39.62 KB)
π
bzcat
(39.62 KB)
π
bzcmp
(2.09 KB)
π
bzdiff
(2.09 KB)
π
bzgrep
(2.01 KB)
π
bzip2
(39.62 KB)
π
bzip2recover
(15.4 KB)
π
bzless
(1.23 KB)
π
bzmore
(1.23 KB)
π
c++
(1.04 MB)
π
c++filt
(27.18 KB)
π
cagefs_enter.proxied
(1.27 KB)
π
cal
(52.01 KB)
π
captoinfo
(87.8 KB)
π
cat
(35.66 KB)
π
catchsegv
(3.21 KB)
π
cc
(0 B)
π
ccmake
(6.96 MB)
π
chcon
(60.24 KB)
π
chgrp
(56.19 KB)
π
chmod
(56.16 KB)
π
chown
(60.19 KB)
π
chrt
(27.48 KB)
π
cksum
(35.57 KB)
π
clear
(15.16 KB)
π
cloudlinux-awp-user
(1.78 KB)
π
clwpos-user
(1.78 KB)
π
cmake
(7.45 MB)
π
cmp
(40.13 KB)
π
col
(23.41 KB)
π
colcrt
(15.38 KB)
π
colrm
(15.36 KB)
π
column
(35.52 KB)
π
comm
(35.75 KB)
π
cp
(149.24 KB)
π
cpack
(7.35 MB)
π
cpp
(1.04 MB)
π
csplit
(108.88 KB)
π
ctest
(8.31 MB)
π
curl
(248.49 KB)
π
cut
(47.8 KB)
π
cyrusbdb2current
(1.58 MB)
π
date
(104.05 KB)
π
dbiprof
(6.06 KB)
π
delv
(45.38 KB)
π
df
(84.73 KB)
π
diff
(194.7 KB)
π
diff3
(52.3 KB)
π
dig
(136.59 KB)
π
dir
(137.65 KB)
π
dircolors
(39.8 KB)
π
dirname
(31.48 KB)
π
dltest
(15.68 KB)
π
dnstap-read
(23.19 KB)
π
du
(149.44 KB)
π
echo
(35.48 KB)
π
ed
(52.51 KB)
π
egrep
(32 B)
π
enchant
(23.73 KB)
π
enchant-lsmod
(15.8 KB)
π
env
(44.23 KB)
π
eps2eps
(643 B)
π
eqn
(189.52 KB)
π
ex
(1.38 MB)
π
expand
(39.73 KB)
π
expr
(108.6 KB)
π
factor
(72.05 KB)
π
false
(27.47 KB)
π
fc-cache
(139 B)
π
fc-cache-64
(23.17 KB)
π
fc-cat
(19.16 KB)
π
fc-conflist
(15.13 KB)
π
fc-list
(15.13 KB)
π
fc-match
(15.13 KB)
π
fc-pattern
(15.14 KB)
π
fc-query
(15.13 KB)
π
fc-scan
(15.14 KB)
π
fc-validate
(15.14 KB)
π
fgrep
(32 B)
π
file
(27.74 KB)
π
find
(284.95 KB)
π
flock
(23.56 KB)
π
fmt
(39.77 KB)
π
fold
(39.71 KB)
π
free
(23.36 KB)
π
funzip
(31.42 KB)
π
g++
(1.04 MB)
π
gawk
(698.17 KB)
π
gcc-ar
(27.81 KB)
π
gcc-nm
(27.8 KB)
π
gcc-ranlib
(27.82 KB)
π
gcov-dump
(283.74 KB)
π
gcov-tool
(312.46 KB)
π
gem
(542 B)
π
gencat
(27.45 KB)
π
geoiplookup
(15.86 KB)
π
geoiplookup6
(15.81 KB)
π
geqn
(189.52 KB)
π
getconf
(35.23 KB)
π
getent
(35.86 KB)
π
getopt
(23.45 KB)
π
ghostscript
(15.13 KB)
π
gifdiff
(55.9 KB)
π
gifsicle
(194.05 KB)
π
git
(4.06 MB)
π
git-receive-pack
(4.06 MB)
π
git-shell
(770.68 KB)
π
git-upload-archive
(4.06 MB)
π
git-upload-pack
(4.06 MB)
π
gm
(15.67 KB)
π
gmake
(249.8 KB)
π
gneqn
(916 B)
π
gnroff
(3.21 KB)
π
gpg
(1.07 MB)
π
gpg-agent
(342.25 KB)
π
gpg-error
(36.1 KB)
π
gpgsplit
(27.49 KB)
π
gpgv
(295.42 KB)
π
gpic
(201.72 KB)
π
gprof
(101.48 KB)
π
grep
(154.49 KB)
π
groff
(96.77 KB)
π
grops
(167.26 KB)
π
grotty
(122.2 KB)
π
groups
(35.66 KB)
π
gs
(15.13 KB)
π
gsnd
(281 B)
π
gsoelim
(0 B)
π
gtar
(514.27 KB)
π
gtbl
(130.86 KB)
π
gtroff
(732.07 KB)
π
gunzip
(2.29 KB)
π
gzexe
(6.3 KB)
π
gzip
(89.63 KB)
π
hdu
(18.09 KB)
π
head
(43.8 KB)
π
hexdump
(51.59 KB)
π
host
(108.57 KB)
π
hostid
(31.66 KB)
π
hostname
(23.84 KB)
π
hunspell
(102.67 KB)
π
iconv
(64.09 KB)
π
id
(39.71 KB)
π
idn
(35.8 KB)
π
ifnames
(4.03 KB)
π
infocmp
(63.69 KB)
π
infotocap
(87.8 KB)
π
install
(149.29 KB)
π
ionice
(15.4 KB)
π
ipcrm
(19.41 KB)
π
ipcs
(39.52 KB)
π
isosize
(15.34 KB)
π
ispell
(992 B)
π
isql
(40.01 KB)
π
iusql
(31.95 KB)
π
join
(51.9 KB)
π
jpegoptim
(48.83 KB)
π
kill
(31.47 KB)
π
ld
(1.71 MB)
π
ld.bfd
(1.71 MB)
π
ldd
(5.32 KB)
π
less
(197.9 KB)
π
lessecho
(15.37 KB)
π
lesskey
(24.8 KB)
π
lesspipe.sh
(3.5 KB)
π
link
(31.66 KB)
π
ln
(60.16 KB)
π
locale
(59.08 KB)
π
localedef
(314.06 KB)
π
logger
(36.16 KB)
π
login
(43.62 KB)
π
logname
(31.66 KB)
π
look
(19.36 KB)
π
ls
(137.64 KB)
π
lto-dump
(26.58 MB)
π
m4
(240.4 KB)
π
make
(249.8 KB)
π
make-dummy-cert
(614 B)
π
mariadb
(5.12 MB)
π
mariadb-access
(109.48 KB)
π
mariadb-admin
(4.89 MB)
π
mariadb-binlog
(5.16 MB)
π
mariadb-check
(4.89 MB)
π
mariadb-conv
(4.6 MB)
π
mariadb-convert-table-format
(4.28 KB)
π
mariadb-dump
(4.99 MB)
π
mariadb-dumpslow
(8.19 KB)
π
mariadb-embedded
(24.72 MB)
π
mariadb-find-rows
(3.35 KB)
π
mariadb-hotcopy
(34.67 KB)
π
mariadb-import
(5 MB)
π
mariadb-plugin
(4.58 MB)
π
mariadb-secure-installation
(13.66 KB)
π
mariadb-setpermission
(17.7 KB)
π
mariadb-show
(4.88 MB)
π
mariadb-slap
(4.89 MB)
π
mariadb-tzinfo-to-sql
(4.57 MB)
π
mariadb-waitpid
(4.56 MB)
π
mc
(1.22 MB)
π
mcdiff
(1.22 MB)
π
mcedit
(1.22 MB)
π
mcookie
(27.5 KB)
π
mcview
(1.22 MB)
π
md5sum
(39.64 KB)
π
mesg
(15.33 KB)
π
mkdir
(68.31 KB)
π
mkfifo
(39.83 KB)
π
mknod
(43.88 KB)
π
mktemp
(39.8 KB)
π
more
(43.63 KB)
π
msmtp
(133.98 KB)
π
msmtpd
(35.65 KB)
π
msql2mysql
(1.42 KB)
π
mv
(141.17 KB)
π
my_print_defaults
(4.56 MB)
π
mysql
(5.12 MB)
π
mysql_config
(4.47 KB)
π
mysql_find_rows
(3.35 KB)
π
mysql_waitpid
(4.56 MB)
π
mysqlaccess
(109.48 KB)
π
mysqladmin
(4.89 MB)
π
mysqlbinlog
(5.16 MB)
π
mysqlcheck
(4.89 MB)
π
mysqldump
(4.99 MB)
π
mysqlimport
(5 MB)
π
mysqlshow
(4.88 MB)
π
mytop
(72.03 KB)
π
namei
(23.41 KB)
π
nano
(346.2 KB)
π
neqn
(916 B)
π
nice
(35.67 KB)
π
nl
(100.71 KB)
π
nm
(44.71 KB)
π
nohup
(35.58 KB)
π
nproc
(35.69 KB)
π
nroff
(3.21 KB)
π
nslookup
(112.52 KB)
π
nsupdate
(71.8 KB)
π
numfmt
(55.83 KB)
π
objcopy
(185.37 KB)
π
objdump
(413.09 KB)
π
od
(64.06 KB)
π
odbc_config
(15.7 KB)
π
odbcinst
(23.9 KB)
π
openssl
(1.01 MB)
π
optipng
(92.02 KB)
π
pango-list
(19.11 KB)
π
pango-segmentation
(19.13 KB)
π
pango-view
(60.17 KB)
π
passwd
(1.26 KB)
π
paste
(35.58 KB)
π
patch
(195.02 KB)
π
pathchk
(35.66 KB)
π
pdf2dsc
(701 B)
π
pdf2ps
(913 B)
π
perldoc
(118 B)
π
pgrep
(31.42 KB)
π
php
(10.1 MB)
π
php-cgi
(8.1 MB)
π
phpize
(4.97 KB)
π
pic
(201.72 KB)
π
piconv
(8.08 KB)
π
ping
(76.51 KB)
π
pinky
(35.61 KB)
π
pkill
(31.42 KB)
π
pmap
(35.39 KB)
π
pod2man
(14.68 KB)
π
pod2text
(10.55 KB)
π
pod2usage
(4.01 KB)
π
post-grohtml
(199.76 KB)
π
pr
(72.28 KB)
π
pre-grohtml
(92.92 KB)
π
precat
(5.53 KB)
π
preunzip
(5.53 KB)
π
prezip
(5.53 KB)
π
prezip-bin
(15.69 KB)
π
printenv
(31.47 KB)
π
printf
(51.77 KB)
π
ps
(141.15 KB)
π
ps2ascii
(635 B)
π
ps2epsi
(1.24 KB)
π
ps2pdf
(276 B)
π
ps2pdf12
(219 B)
π
ps2pdf13
(219 B)
π
ps2pdf14
(219 B)
π
ps2pdfwr
(1.06 KB)
π
ps2ps
(651 B)
π
ps2ps2
(673 B)
π
ptx
(129.03 KB)
π
pwd
(35.7 KB)
π
pwdx
(15.28 KB)
π
pydoc
(78 B)
π
pydoc3
(78 B)
π
pydoc3.9
(78 B)
π
python
(15.09 KB)
π
python3
(15.09 KB)
π
python3.9
(15.09 KB)
π
ranlib
(56 KB)
π
readelf
(667.28 KB)
π
readlink
(39.69 KB)
π
realpath
(39.77 KB)
π
recode
(31.93 KB)
π
red
(92 B)
π
rename
(23.41 KB)
π
renew-dummy-cert
(729 B)
π
renice
(15.36 KB)
π
replace
(4.54 MB)
π
reset
(27.34 KB)
π
restic
(28.4 MB)
π
rev
(15.35 KB)
π
rm
(60.21 KB)
π
rmdir
(43.61 KB)
π
rnano
(346.2 KB)
π
rsync
(559.16 KB)
π
rsync-ssl
(5.01 KB)
π
ruby
(15.27 KB)
π
run-with-aspell
(89 B)
π
runcon
(35.65 KB)
π
rvi
(1.38 MB)
π
rview
(1.38 MB)
π
rvim
(3.84 MB)
π
scalar
(819.34 KB)
π
scl
(39.55 KB)
π
scl_enabled
(262 B)
π
scl_source
(1.88 KB)
π
scp
(133.06 KB)
π
script
(51.75 KB)
π
sdiff
(44.2 KB)
π
sed
(114.01 KB)
π
seq
(47.79 KB)
π
setsid
(15.34 KB)
π
setterm
(35.52 KB)
π
sftp
(141.05 KB)
π
sh
(1.32 MB)
π
sha1sum
(39.64 KB)
π
sha224sum
(39.64 KB)
π
sha256sum
(39.64 KB)
π
sha384sum
(39.64 KB)
π
sha512sum
(39.64 KB)
π
shred
(51.88 KB)
π
shuf
(48.01 KB)
π
size
(31.61 KB)
π
skill
(31.4 KB)
π
slabtop
(23.42 KB)
π
sleep
(35.65 KB)
π
slencheck
(15.71 KB)
π
snice
(31.4 KB)
π
soelim
(0 B)
π
sort
(113.09 KB)
π
spell
(125 B)
π
split
(52.31 KB)
π
sprof
(35.45 KB)
π
sqlite3
(1.52 MB)
π
ssh
(843.53 KB)
π
ssh-add
(164.86 KB)
π
ssh-agent
(281.02 KB)
π
ssh-copy-id
(12.38 KB)
π
ssh-keygen
(455.04 KB)
π
ssh-keyscan
(197.43 KB)
π
stat
(80.06 KB)
π
stdbuf
(43.74 KB)
π
strace
(2.08 MB)
π
strings
(31.74 KB)
π
strip
(185.36 KB)
π
stty
(75.83 KB)
π
sum
(35.59 KB)
π
svn
(446.56 KB)
π
svnadmin
(136.45 KB)
π
svndumpfilter
(44.15 KB)
π
svnfsfs
(44.03 KB)
π
svnlook
(92.23 KB)
π
svnrdump
(56.23 KB)
π
svnserve
(112.91 KB)
π
svnsync
(68.41 KB)
π
svnversion
(15.72 KB)
π
sync
(35.54 KB)
π
tabs
(19.16 KB)
π
tac
(104.6 KB)
π
tail
(68.09 KB)
π
tar
(514.27 KB)
π
taskset
(23.41 KB)
π
tbl
(130.86 KB)
π
tclsh
(15.69 KB)
π
tclsh8.6
(15.69 KB)
π
tee
(35.69 KB)
π
test
(43.79 KB)
π
tic
(87.8 KB)
π
timeout
(40.17 KB)
π
tload
(19.34 KB)
π
tmpwatch
(36.03 KB)
π
toe
(23.23 KB)
π
top
(132.27 KB)
π
touch
(92.03 KB)
π
tput
(27.25 KB)
π
tr
(47.87 KB)
π
tree
(85.45 KB)
π
troff
(732.07 KB)
π
true
(27.47 KB)
π
truncate
(35.66 KB)
π
tset
(27.34 KB)
π
tsort
(47.79 KB)
π
tty
(31.65 KB)
π
tzselect
(14.99 KB)
π
ul
(23.45 KB)
π
uname
(31.66 KB)
π
unexpand
(39.73 KB)
π
uniq
(43.83 KB)
π
unlink
(31.66 KB)
π
unrar
(347.02 KB)
π
unzip
(196.14 KB)
π
unzipsfx
(87.89 KB)
π
uptime
(15.29 KB)
π
users
(35.68 KB)
π
utmpdump
(23.4 KB)
π
vdir
(137.65 KB)
π
vi
(691 B)
π
view
(150 B)
π
vim
(3.84 MB)
π
vimdiff
(3.84 MB)
π
vimtutor
(2.07 KB)
π
vmstat
(39.41 KB)
π
watch
(27.87 KB)
π
wc
(43.73 KB)
π
wget
(521.41 KB)
π
whereis
(32.03 KB)
π
which
(27.89 KB)
π
who
(51.77 KB)
π
whoami
(31.66 KB)
π
word-list-compress
(15.7 KB)
π
x86_64-redhat-linux-c++
(1.04 MB)
π
x86_64-redhat-linux-g++
(1.04 MB)
π
x86_64-redhat-linux-gcc-11
(1.04 MB)
π
xargs
(64.09 KB)
π
xmlcatalog
(23.15 KB)
π
xmllint
(80.55 KB)
π
xmlwf
(39.63 KB)
π
xsltproc
(31.23 KB)
π
xxd
(19.31 KB)
π
yes
(31.51 KB)
π
zcat
(1.94 KB)
π
zcmp
(1.64 KB)
π
zdiff
(6.31 KB)
π
zegrep
(33 B)
π
zfgrep
(33 B)
π
zforce
(2.04 KB)
π
zgrep
(7.93 KB)
π
zip
(221.09 KB)
π
zipcloak
(75.7 KB)
π
zipgrep
(2.89 KB)
π
zipinfo
(196.14 KB)
π
zipnote
(67.61 KB)
π
zipsplit
(63.58 KB)
π
zless
(2.16 KB)
π
zmore
(1.8 KB)
π
znew
(4.47 KB)
π
zsoelim
(0 B)
Editing: ssh-copy-id
#!/usr/bin/sh # Copyright (c) 1999-2020 Philip Hands <phil@hands.com> # 2020 Matthias BlΓΌmel <blaimi@blaimi.de> # 2017 Sebastien Boyron <seb@boyron.eu> # 2013 Martin Kletzander <mkletzan@redhat.com> # 2010 Adeodato =?iso-8859-1?Q?Sim=F3?= <asp16@alu.ua.es> # 2010 Eric Moret <eric.moret@gmail.com> # 2009 Xr <xr@i-jeuxvideo.com> # 2007 Justin Pryzby <justinpryzby@users.sourceforge.net> # 2004 Reini Urban <rurban@x-ray.at> # 2003 Colin Watson <cjwatson@debian.org> # 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 <ssh -o options>] ...] [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 if [ "$?" = "$L_SUCCESS" ] || { [ "$SFTP" ] && grep 'allows sftp connections only' "$L_OUTPUT_FILE" >/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 # =-=-=-=
Upload File
Create Folder