ssh
: OpenSSH SSH client (remote login program) OpenSSH SSH客户端(远程登录程序)ssh-keygen
: authentication key generation, management and conversion 生成、管理、转换用于认证的密钥ssh-agent
: authentication agent认证代理(复杂情景才可能用到,通常使用不到)上面三个程序具体能够在Unix类系统输入man ssh
, man ssh-keygen
, man ssh-agent
,查看详细的说明和下述流程涉及的参数意思 ${variable}
按照变量字面意思,根据实际状况,写入具体的值[optional]
可选git
ssh-keygen -t rsa -C ${github_email}
->Enter file name ${github_key}
-> Password: null or ${custom_github_password}
ssh-keygen -t rsa -C "${gitlab_email}"
->Enter file name ${gitlab_key}
-> Password: null or ${custom_gitlab_password}
${github_key}[.pub]
和${gitlab_key}[.pub]
公私钥放在C:\User\${Username}\.ssh
目录下面${github_key}.pub
和${gitlab_key}.pub
文件内容用记事本打开,而后拷贝到相应的Github或Gitlab上面,操做路径为:settings -> SSH and GPG keys -> add new key
在.ssh
目录建立config
文本文件,并将.txt
扩展后缀去掉。每一个帐号单独配置一个Host,每一个Host取一个对应的域名或者IP地址,每一个Host主要配置HostName和IdentityFile两个属性便可。github
git@Host
中的Host
字段Host
对应${github_key}
或${gitlab_key}
文件全路径publickey, password publickey
# github Host github.com HostName github.com IdentityFile C:\Users\${Username}\.ssh\github_id_rsa PreferredAuthentications publickey User github # custom gitlab Host ${gitlab_ip} HostName ${gitlab_ip} IdentityFile C:\Users\${Username}\.ssh\gitlab_id_rsa PreferredAuthentications publickey User gitlab
ssh -Tv git@github.com
根据显示的信息,跟踪整个ssh
的流程ssh
Host
是域名或准确的IP地址,必定要配置填写正确ssh-keygen
如有使用密码,后续的ssh
也须要密码才能访问对应的本地私钥