Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This is a simple bash script to reproduce ssh-copy-id behavior on the Mac OS, since this shit OS doesn't have it natively.
#!/bin/bash
# This is a simple shell script to reproduce ssh-copy-id behavior
# on the MAC, since that shit OS does not have it natively.
#
# This script is under GPL version 3
# Author: Kemel Zaidan
# email: kemelzaidan AT gmail DOT com
# website: kemelzaidan.com.br
#
## VARIABLES
SSH_PUB_KEY=~/.ssh/id_rsa.pub
USER=$1
HOST=$2
# exit if no atributes were passed
if [ $# -eq 0 ]; then
echo ""
echo "Please, type ssh-copy-id USER HOST"
echo ""
exit 1
fi
# test if there is a SSH public key
if [ ! -f $SSH_PUB_KEY ]; then
echo 'No public SSH key found!'
exit 1
fi
cat $SSH_PUB_KEY | ssh $USER@$HOST "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"
# exit if successfull
echo ""
echo "Key successfully copied to the server"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.