
为什么使用SSH的方式如何将Git提交代码的http方式换成ssh方式1. 生成ssh的秘钥ssh-keygen -t rsa -b 4096 -C 你的git邮箱 密码可以不设置直接enter【 生成的秘钥默认在 ~/.ssh文件下公钥和私钥】【 复制文件内容到剪切板clip 路径 (window系统) 】2. 登录git账户将秘钥的 公钥 复制到 “SSH keys“ 管理员3. 设置/更改 指定远程仓库的URLgit remote set-url origin 新地址查看git登录的用户git config --global user.name your_usernamegit config --global user.email your_emailexample.comgit config --list显示所有远程仓库git remote -v更改远程仓库URLgit remote set-url origin 项目远程仓库路径4. 在ssh客户端配置 私钥以pycharm为例setting - tools - ssh configurationshost: 服务器的ip或者域名xxx.comport: 服务器的端口user name: 随意authentication type: 密钥对Key pairprivate key file: 私钥的文件路径最后进行Test Connection遇到的问题push的时候提示类似没有什么权限询问是否继续yes之后会给出一个警告信息Warning: Permanently added gitlab.jiufengxinxi.com,49.234.21.109 (ECDSA) to the list of known hosts.原因SSH客户端已经将该服务器的主机密钥公钥永久添加到了你本地机器上的known_hosts文件中这样做可以确保你的机器只会在第一次连接到服务器时提示你确认服务器的真实性并防止未来的连接中对服务器的真实性进行重复验证。