首页 分享 Generating Your SSH Public Key

Generating Your SSH Public Key

来源:花匠小妙招 时间:2025-08-14 16:41

Chapters ▾

1. Getting Started

1.1 About Version Control 1.2 A Short History of Git 1.3 What is Git? 1.4 The Command Line 1.5 Installing Git 1.6 First-Time Git Setup 1.7 Getting Help 1.8 Summary

2. Git Basics

2.1 Getting a Git Repository 2.2 Recording Changes to the Repository 2.3 Viewing the Commit History 2.4 Undoing Things 2.5 Working with Remotes 2.6 Tagging 2.7 Git Aliases 2.8 Summary

3. Git Branching

3.1 Branches in a Nutshell 3.2 Basic Branching and Merging 3.3 Branch Management 3.4 Branching Workflows 3.5 Remote Branches 3.6 Rebasing 3.7 Summary

4. Git on the Server

4.1 The Protocols 4.2 Getting Git on a Server 4.3 Generating Your SSH Public Key 4.4 Setting Up the Server 4.5 Git Daemon 4.6 Smart HTTP 4.7 GitWeb 4.8 GitLab 4.9 Third Party Hosted Options 4.10 Summary

5. Distributed Git

5.1 Distributed Workflows 5.2 Contributing to a Project 5.3 Maintaining a Project 5.4 Summary

6. GitHub

6.1 Account Setup and Configuration 6.2 Contributing to a Project 6.3 Maintaining a Project 6.4 Managing an organization 6.5 Scripting GitHub 6.6 Summary

7. Git Tools

7.1 Revision Selection 7.2 Interactive Staging 7.3 Stashing and Cleaning 7.4 Signing Your Work 7.5 Searching 7.6 Rewriting History 7.7 Reset Demystified 7.8 Advanced Merging 7.9 Rerere 7.10 Debugging with Git 7.11 Submodules 7.12 Bundling 7.13 Replace 7.14 Credential Storage 7.15 Summary

8. Customizing Git

8.1 Git Configuration 8.2 Git Attributes 8.3 Git Hooks 8.4 An Example Git-Enforced Policy 8.5 Summary

9. Git and Other Systems

9.1 Git as a Client 9.2 Migrating to Git 9.3 Summary

10. Git Internals

10.1 Plumbing and Porcelain 10.2 Git Objects 10.3 Git References 10.4 Packfiles 10.5 The Refspec 10.6 Transfer Protocols 10.7 Maintenance and Data Recovery 10.8 Environment Variables 10.9 Summary

A1. Appendix A: Git in Other Environments

A1.1 Graphical Interfaces A1.2 Git in Visual Studio A1.3 Git in Visual Studio Code A1.4 Git in IntelliJ / PyCharm / WebStorm / PhpStorm / RubyMine A1.5 Git in Sublime Text A1.6 Git in Bash A1.7 Git in Zsh A1.8 Git in PowerShell A1.9 Summary

A2. Appendix B: Embedding Git in your Applications

A2.1 Command-line Git A2.2 Libgit2 A2.3 JGit A2.4 go-git A2.5 Dulwich

A3. Appendix C: Git Commands

A3.1 Setup and Config A3.2 Getting and Creating Projects A3.3 Basic Snapshotting A3.4 Branching and Merging A3.5 Sharing and Updating Projects A3.6 Inspection and Comparison A3.7 Debugging A3.8 Patching A3.9 Email A3.10 External Systems A3.11 Administration A3.12 Plumbing Commands

2nd Edition

4.3 Git on the Server - Generating Your SSH Public Key

Many Git servers authenticate using SSH public keys. In order to provide a public key, each user in your system must generate one if they don’t already have one. This process is similar across all operating systems. First, you should check to make sure you don’t already have a key. By default, a user’s SSH keys are stored in that user’s ~/.ssh directory. You can easily check to see if you have a key already by going to that directory and listing the contents:

$ cd ~/.ssh $ ls authorized_keys2 id_dsa known_hosts config id_dsa.pub

You’re looking for a pair of files named something like id_dsa or id_rsa and a matching file with a .pub extension. The .pub file is your public key, and the other file is the corresponding private key. If you don’t have these files (or you don’t even have a .ssh directory), you can create them by running a program called ssh-keygen, which is provided with the SSH package on Linux/macOS systems and comes with Git for Windows:

$ ssh-keygen -o Generating public/private rsa key pair. Enter file in which to save the key (/home/schacon/.ssh/id_rsa): Created directory '/home/schacon/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/schacon/.ssh/id_rsa. Your public key has been saved in /home/schacon/.ssh/id_rsa.pub. The key fingerprint is: d0:82:24:8e:d7:f1:bb:9b:33:53:96:93:49:da:9b:e3 schacon@mylaptop.local

First it confirms where you want to save the key (.ssh/id_rsa), and then it asks twice for a passphrase, which you can leave empty if you don’t want to type a password when you use the key. However, if you do use a password, make sure to add the -o option; it saves the private key in a format that is more resistant to brute-force password cracking than is the default format. You can also use the ssh-agent tool to prevent having to enter the password each time.

Now, each user that does this has to send their public key to you or whoever is administrating the Git server (assuming you’re using an SSH server setup that requires public keys). All they have to do is copy the contents of the .pub file and email it. The public keys look something like this:

$ cat ~/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSU GPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3 Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XA t3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/En mZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbx NrRFi9wrf+M7Q== schacon@mylaptop.local

相关知识

Mozilla Public License 2.0
Public disclosures of vulnerabilities
实战配置ubuntu下的vim开发环境
SSH(Spring+Hibernate+Struts)整合开发鲜花礼品网站源码
Yoast SEO – Advanced SEO with real
GIT ssh 无法连接解决方法 22 connection
如何实现SSH断开后 进程仍然在后台运行
linux ssh如何设置登陆超时与不超时方法
Java高效计数器
hadoop常见错误及解决办法!

网址: Generating Your SSH Public Key https://www.huajiangbk.com/newsview2259823.html

所属分类:花卉
上一篇: 南京特殊教育师范学院学生信息技术
下一篇: 我见到的山东本土植物和园林栽培植

推荐分享