-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinfect
More file actions
executable file
·21 lines (16 loc) · 807 Bytes
/
infect
File metadata and controls
executable file
·21 lines (16 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#/bin/sh
# install key on remote server for no-password login
SERVER="$1"
[ -z "$SERVER" ] && echo -n "Enter server or user@server: " && read SERVER
USER="${SERVER%@*}"
[ "$USER" = "$SERVER" ] && USER="root"
SERVER="${SERVER#*@}"
[ -z "$USER" ] && USER=`whoami`
# generate our local key
[ ! -d ~/.ssh ] && mkdir -p ~/.ssh
[ ! -f ~/.ssh/id_dsa.pub ] && ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
KEYHOLDER=$(cut -d ' ' -f 3 ~/.ssh/id_dsa.pub)
echo "Installing key on $USER@$SERVER..."
ssh $USER@$SERVER "mkdir -p ~/.ssh;[ -f ~/.ssh/authorized_keys ] && sed -i "/$KEYHOLDER/d" ~/.ssh/authorized_keys;cat >>~/.ssh/authorized_keys; chmod 644 ~/.ssh/authorized_keys" <~/.ssh/id_dsa.pub
echo "Copying additional files..."
tar cf - -C ~ bin .gitconfig .ssh/id_dsa .ssh/id_dsa.pub |ssh $USER@$SERVER "tar xf -"