开发者

Copying my git public keys. Do i copy the keys as my user or as my git user?

开发者 https://www.devze.com 2023-02-09 02:12 出处:网络
I have a git server (gitosis) on a Ubuntu box (10.10).I use a macpro at work, and a macpro at home as my dev computer. I would like to check out the projects on my laptop (running windows 7)

I have a git server (gitosis) on a Ubuntu box (10.10).I use a macpro at work, and a macpro at home as my dev computer. I would like to check out the projects on my laptop (running windows 7)

I was able to copy my s开发者_开发百科sh key from my work computer and import it into my home dev station. Now i want to import the key to my windows laptop.

How do i import a public key (id_dsa.pub) to my laptop.

Or,better yet, how do i use multiple keys on the server?

I found this instruction: ssh user@hostname "echo cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys"

but im not suer if "user@hostname" should be my local user or should it be my git@localhsot user?

thanks for any advice


You need to copy the keys to the remote user you intend to ssh in as.

That'll be the git user on the remote, presumably, since when you push you'll be using git@host:path as a URL - that means "ssh into host as git, and interact with the repo at ".

Perhaps it'd help if you understood that the keys are used as a sort of handshake: you, as your local user, talk to the machine on the other end and say, "Hi, I'm git. Here is my private key. Can I come in?" The remote looks in its lists of authorized keys for the git user and says, "Aha, here's the public key that fits that private key. You're good to go."


The important part is: you don't copy anyones public keys to your laptop, but you create a new keypair on the laptop, and then copy the public key of this local account in the authorized_keys to the account you want to log into (which in this case would be the gitosis user account). For gitosis, you'll have to change the key a bit (I think the last comment part) - read the gitosis documentation for this.

The command you found copies the public key of the same account to the authorized_keys, which is mostly useless (if you don't use the same account per shared file system on several systems, and want to connect from one of these to another).

0

精彩评论

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

关注公众号