Last active
October 1, 2018 06:32
-
-
Save sukobuto/469269891536ed6cedcc0e79318315f7 to your computer and use it in GitHub Desktop.
Generate deploy key on server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
keyname=$1 | |
if [ $# -lt 1 ] | |
then | |
echo "usage: ./github_deploy_key.sh <keyname>" | |
exit 1 | |
fi | |
expect -c " | |
set timeout 5 | |
spawn ssh-keygen -t rsa -f .ssh/github_${keyname} | |
expect \": \" | |
send \"\n\" | |
expect \"Enter passphrase (empty for no passphrase): \" | |
send \"\n\" | |
expect \"Enter same passphrase again: \" | |
send \"\n\" | |
wait | |
" | |
echo -e "\n\n===== usage =====" | |
echo "git clone github_${keyname}:<user or org>/<rep name>" | |
echo -e "\n===== copy & paste into github deploy key =====" | |
cat << EOS >> .ssh/config | |
Host github_${keyname} | |
HostName github.com | |
Port 22 | |
User git | |
IdentityFile ~/.ssh/github_${keyname} | |
EOS | |
cat .ssh/github_${keyname}.pub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage:
install requirements
download
use