Copy folder to remote server
REMOTE=server.fqdn
sudo tar -cz -C ` pwd` . \
| ssh " $REMOTE " " sudo mkdir -p $( pwd) && sudo tar --same-owner --same-permissions -xzv -C $( pwd) "
Allow sudo without password on remote server
REMOTE=server.fqdn
USER=username
ssh -tt " $REMOTE " " sudo sh -c 'echo \" ${USER} ALL=(ALL) NOPASSWD:ALL\" > /etc/sudoers.d/${USER/ ./ _} '"
Disallow sudo without password on remote server
REMOTE=server.fqdn
ssh -tt " $REMOTE " " sudo sh -c 'echo \"\" > /etc/sudoers.d/${USER/ ./ _} '"
Copy all docker images to remote server
SSH_TARGET=user@server.fqdn
for image in ` docker images --format ' {{ .Repository }}:{{ .Tag }}' ` ; do
docker save $image | ssh " $SSH_TARGET " docker load
done
Copy docker volume to remote server
SSH_TARGET=user@host
VOLUME_NAME=volume
ssh " $SSH_TARGET " ' docker volume create ' " $VOLUME_NAME " ' ' ;
docker run --rm -v $VOLUME_NAME :/from alpine ash -c " cd /from ; tar -cf - . " \
| ssh " $SSH_TARGET " ' docker run --rm -i -v ' " $VOLUME_NAME " ' :/to alpine ash -c "cd /to ; tar -xpvf - " ' ;