git-push with specific SSH key
来源:互联网 发布:淘宝和天猫有什么区别 编辑:程序博客网 时间:2024/06/05 07:06
Thursday, 11 August 2011
I figured this was worth a post, as I’ve never ran into this problem before. I’ve been working on setting up a server, to which I connect using RSA. The standard name for an RSA key file isid_rsa(.pub)
. However, as I use my ‘standard’ key elsewhere, I wanted to use a specific key for this server.
Connecting via SSH to the server with the key is as simple as adding -i /path/to/key
. The problem arose when I needed to be able to push to a Git repository hosted on the server, and adding-i
to git-push
doesn’t work.
The solution was to add a Host
directive to my ~/.ssh/config
file. Then, use thatHost
to connect to when push
’ing to the remote server.
If it doesn’t exist, create the file ~/.ssh/config
. Add the following to it, editing where necessary.
Host RemoteServer HostName remote-server.tld User git IdentityFile ~/.ssh/remoteserver_key
Remember to reload SSH after creating this file. This example config would be the equivalent of running a command likessh git@remote-server.tld -i ~/.ssh/remoteserver_key
. You can even runssh RemoteServer
to test the connection out.
In your Git repository, add a new remote repository. Here I’ve called it origin
, as the convention might have it.
git remote add origin RemoteServer:path/to/repository.git
Instead of specifying a user @
a domain, it uses the name of the Host
in the SSH config. The path/to/repository.git
is relative, on the average system, that will probably point to/home/git/path/to/repository.git
.
Try running a git push origin master
to see if it works!
- git-push with specific SSH key
- Git学习笔记三(创建Github SSH Key、git push、git clone)
- git push 使用ssh
- Git: Add submodule with a specific version
- git ssh key
- git 私服 ssh key
- git设置ssh key
- git生成ssh key
- git ssh key
- Git 设置SSH Key
- git 生成SSH KEY
- Git SSH Key生成
- git 设置 ssh key
- git生成ssh key
- git ssh key
- git 添加ssh key
- git ssh-key
- GIT 生成 SSH key
- Android apk动态加载机制的研究
- windows键盘的过滤(HOOK分发函数)
- linux内核中list_head使用介绍
- 程序员学习能力提升三要素
- 杭电2211杀人游戏
- git-push with specific SSH key
- NYOJ737石子合并&NKOJ 圆形操场
- NYOJ 692 Chinese checkers(广搜)
- CRC校验
- Android apk动态加载机制的研究(二):资源加载和activity生命周期管理
- 使用BlazeDS与java类进行通信时容易报的错误
- javax.mail.NoSuchProviderException: smtp 报错
- 判断是否新版本
- VMware 虚拟机中添加新硬盘的方法