Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. with_key("/home/christoffer/ssh_keys/theuser") do
  2. sh("git clone git@github.com:TheUser/TheProject.git")
  3. end
  4.  
  5. ssh-agent bash -c 'ssh-add /somewhere/yourkey; git clone git@github.com:user/project.git'
  6.  
  7. ssh-agent $(ssh-add /somewhere/yourkey; git clone git@github.com:user/project.git)
  8.  
  9. Host gitserv
  10. Hostname remote.server.com
  11. IdentityFile ~/.ssh/id_rsa.github
  12. IdentitiesOnly yes # see NOTES below
  13.  
  14. git remote add origin git@gitserv:myrepo.git
  15.  
  16. git push -v origin master
  17.  
  18. Host github.com
  19. IdentityFile ~/.ssh/github_rsa
  20.  
  21. GIT_SSH_COMMAND='ssh -i private_key_file' git clone host:repo.git
  22.  
  23. #!/bin/bash
  24.  
  25. ssh -i /path/to/ssh/secret/key $1 $2
  26.  
  27. GIT_SSH=my_git_ssh_wrapper git clone git@github.com:TheUser/TheProject.git
  28.  
  29. Host github.com
  30. HostName github.com
  31. IdentityFile /path/to/your/personal/github/private/key
  32. User dandv
  33.  
  34. Host github-work
  35. HostName github.com
  36. IdentityFile /path/to/your/work/github/private/key
  37. User workuser
  38.  
  39. #!/bin/bash
  40. ssh -i ~/.ssh/gitkey_rsa "$@"
  41.  
  42. export GIT_SSH=~/gitwrap.sh
  43.  
  44. Host (a space separated list of made up aliases you want to use for the host)
  45. User git
  46. Hostname (ip or hostname of git server)
  47. PreferredAuthentications publickey
  48. IdentityFile ~/.ssh/id_rsa_(the key you want for this repo)
  49.  
  50. core.sshCommand:
  51.  
  52. cd /path/to/my/repo
  53. git config core.sshCommand 'ssh -i private_key_file'
  54. # later on
  55. git clone host:repo.git
  56.  
  57. git config core.sshCommand "ssh -i ~/.ssh/id_rsa_example -F /dev/null"
  58. git pull
  59. git push
  60.  
  61. Host *
  62. User git
  63. Hostname github.com
  64. PreferredAuthentications publickey
  65. IdentityFile ~/.ssh/id_rsa_xxx
  66.  
  67. git -i ~/.ssh/thatuserkey.pem clone thatuser@myserver.com:/git/repo.git
  68.  
  69. git.sh -i ~/.ssh/thatuserkey.pem clone thatuser@myserver.com:/git/repo.git
  70.  
  71. #!/bin/bash
  72.  
  73. # The MIT License (MIT)
  74. # Copyright (c) 2013 Alvin Abad
  75. # https://alvinabad.wordpress.com/2013/03/23/how-to-specify-an-ssh-key-file-with-the-git-command
  76.  
  77. if [ $# -eq 0 ]; then
  78. echo "Git wrapper script that can specify an ssh-key file
  79. Usage:
  80. git.sh -i ssh-key-file git-command
  81. "
  82. exit 1
  83. fi
  84.  
  85. # remove temporary file on exit
  86. trap 'rm -f /tmp/.git_ssh.$$' 0
  87.  
  88. if [ "$1" = "-i" ]; then
  89. SSH_KEY=$2; shift; shift
  90. echo "ssh -i $SSH_KEY $@" > /tmp/.git_ssh.$$
  91. chmod +x /tmp/.git_ssh.$$
  92. export GIT_SSH=/tmp/.git_ssh.$$
  93. fi
  94.  
  95. # in case the git command is repeated
  96. [ "$1" = "git" ] && shift
  97.  
  98. # Run the git command
  99. git "$@"
  100.  
  101. 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