Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with_key("/home/christoffer/ssh_keys/theuser") do
- sh("git clone git@github.com:TheUser/TheProject.git")
- end
- ssh-agent bash -c 'ssh-add /somewhere/yourkey; git clone git@github.com:user/project.git'
- ssh-agent $(ssh-add /somewhere/yourkey; git clone git@github.com:user/project.git)
- Host gitserv
- Hostname remote.server.com
- IdentityFile ~/.ssh/id_rsa.github
- IdentitiesOnly yes # see NOTES below
- git remote add origin git@gitserv:myrepo.git
- git push -v origin master
- Host github.com
- IdentityFile ~/.ssh/github_rsa
- GIT_SSH_COMMAND='ssh -i private_key_file' git clone host:repo.git
- #!/bin/bash
- ssh -i /path/to/ssh/secret/key $1 $2
- GIT_SSH=my_git_ssh_wrapper git clone git@github.com:TheUser/TheProject.git
- Host github.com
- HostName github.com
- IdentityFile /path/to/your/personal/github/private/key
- User dandv
- Host github-work
- HostName github.com
- IdentityFile /path/to/your/work/github/private/key
- User workuser
- #!/bin/bash
- ssh -i ~/.ssh/gitkey_rsa "$@"
- export GIT_SSH=~/gitwrap.sh
- Host (a space separated list of made up aliases you want to use for the host)
- User git
- Hostname (ip or hostname of git server)
- PreferredAuthentications publickey
- IdentityFile ~/.ssh/id_rsa_(the key you want for this repo)
- core.sshCommand:
- cd /path/to/my/repo
- git config core.sshCommand 'ssh -i private_key_file'
- # later on
- git clone host:repo.git
- git config core.sshCommand "ssh -i ~/.ssh/id_rsa_example -F /dev/null"
- git pull
- git push
- Host *
- User git
- Hostname github.com
- PreferredAuthentications publickey
- IdentityFile ~/.ssh/id_rsa_xxx
- git -i ~/.ssh/thatuserkey.pem clone thatuser@myserver.com:/git/repo.git
- git.sh -i ~/.ssh/thatuserkey.pem clone thatuser@myserver.com:/git/repo.git
- #!/bin/bash
- # The MIT License (MIT)
- # Copyright (c) 2013 Alvin Abad
- # https://alvinabad.wordpress.com/2013/03/23/how-to-specify-an-ssh-key-file-with-the-git-command
- if [ $# -eq 0 ]; then
- echo "Git wrapper script that can specify an ssh-key file
- Usage:
- git.sh -i ssh-key-file git-command
- "
- exit 1
- fi
- # remove temporary file on exit
- trap 'rm -f /tmp/.git_ssh.$$' 0
- if [ "$1" = "-i" ]; then
- SSH_KEY=$2; shift; shift
- echo "ssh -i $SSH_KEY $@" > /tmp/.git_ssh.$$
- chmod +x /tmp/.git_ssh.$$
- export GIT_SSH=/tmp/.git_ssh.$$
- fi
- # in case the git command is repeated
- [ "$1" = "git" ] && shift
- # Run the git command
- git "$@"
- bash -c 'eval `ssh-agent`; ssh-add /home/myname/.dotfiles/gitread; ssh-add -L; cd /home/myname/.dotfiles && git pull; kill $SSH_AGENT_PID'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement