开发者

Git - ssh key / ip address

When I set up Git, I did it while using a dsl modem, and my ip isn't static, so when I generated the ssh keys for Git, it was based on that ip.

When I'm assigned an ip other than the one used to generate the ssh Git keys, I can manually change the ip address to the one used to generate the keys. What are my other options to bypass this step? Dynamic DNS? Is there another way?

Update:

OK, so the key isn't influenced by the ip address. I did a git push origin master 开发者_开发知识库and got a not recognized key error and thought it was the ip address. I'll have to try and regenerate that error.


SSH keys don't use your IP address for generation or identification at all. You'll only have problems if you set up some sort of IP filtering on the machine that you're connecting to, "Only allow SSH connections for this user from a certain IP address."

The only other time you would run into issues would be if the machine that you are connecting to got a new IP address, as you SSH client would notice differences compared to your known_hosts file (~/.ssh/known_hosts). This is to protect against man in the middle attacks. If you expected the IP to change, then you'd simply remove the no longer valid line from your known_hosts file.

Cheers.


I'm not sure what factors are taken into account when creating an ssh key for Git, but you won't need to recreate / edit your key each time your IP changes. I've created 3 or 4 keys on various computers for use with Github. All of them were created whilst on a dynamic IP and have been used many times since without the need to make any edits.


I should have been clearer in my question, I wasn't using GitHub - the Git server in question is my own laptop, not GitHub, so it was the server ip that was changing on the whim of the modem/router.

What I did to resolve this was for each ip, to puttygen a key pair. I then added the public key to the authorized_keys file, kept a copy of the private key for my other machines and did a putty for each ip address to add the key to putty's cache. Now I just do this for each ip assigned by the modem. A pain, but only once rather than changing ips all the time.

I do have to update the remote section of the config file in the .git directory to the ip address though. I guess I could add a separate section for each ip address in the remote section based on the ip address, plus a corresponding branch section.

This was the error I was getting:

The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:...
Connection abandoned.
fatal: The remote end hung up unexpectedly

My setup is on Windows 7 and consists of Cygwin (ssh only), msysgit and the putty suite.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜