Generating public/private rsa key pair.> Enter a file in which to save the key (/home/you/.ssh/id_rsa): [Press enter]> Enter passphrase (empty for no passphrase): [Typ_attempts to s">
当前位置:   article > 正文

Github简易上手指南The authenticity of host github.com can‘t be established 如何生成SSH-key_attempts to ssh to github

attempts to ssh to github

第一步按照官方教程生成SSH公钥和私钥

  1. ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  2. > Generating public/private rsa key pair.
  3. > Enter a file in which to save the key (/home/you/.ssh/id_rsa): [Press enter]
  4. > Enter passphrase (empty for no passphrase): [Type a passphrase]
  5. > Enter same passphrase again: [Type passphrase again]

可以按照默认路径和文件生成,路径位于home/xxx/.ssh/id_rsa,如果输入文件名后会将公钥和私钥文件保存到当前目录下。

然后启动ssh代理并且将私钥添加到代理

  1. $ eval "$(ssh-agent -s)"
  2. > Agent pid 59566
  3. ssh-add ~/.ssh/id_rsa

然后打开公钥(.pub文件)并复制或用命令行

  1. $ sudo apt-get install xclip
  2. # Downloads and installs xclip. If you don't have `apt-get`, you might need to use another installer (like `yum`)
  3. $ xclip -sel clip < ~/.ssh/id_rsa.pub
  4. # Copies the contents of the id_rsa.pub file to your clipboard

登陆Github后选择设置下 SSH and GPG keys,选择SSH key添加,名字随意,粘贴公钥。

最后:测试SSH连接成功!

  1. ssh -T git@github.com
  2. # Attempts to ssh to GitHub
  3. Warning: Permanently added the RSA host key for IP address '140.82.121.3' to the list of known hosts.
  4. Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.

第二步将本地仓库全部添加到REMOTE

进入你想保存的目录下打开终端

  1. git init
  2. git add .
  3. #添加所有文件
  4. git commit -m "Initial commit"
  5. git remote add origin https://github.com/xxx/repo_test.git

将本地仓库关联到远程仓库,如果显示已存在origin,删除所有源

  1. git remote rm origin
  2. git remote -v
  3. #查看是否正确

最后一步上传到远端

git push origin master

当你想进行上传操作时,步骤如下:

  1. git add .
  2. #确保上传所有文件
  3. git commit -m "20201020 username"
  4. git remote -v
  5. #查看origin位置是否正确
  6. eval "$(ssh-agent -s)"
  7. #启动SSH客户端
  8. > Agent pid 59566
  9. ssh-add ~/.ssh/ratslam
  10. #添加你的私钥文件名称
  11. ssh -T git@github.com
  12. #测试连接是否成功
  13. > Hi XXX! You've successfully authenticated, but GitHub does not provide shell access.
  14. git push origin master
  15. #最后一步执行上传操作

因为ssh代理只对当前终端有效,因此需要在这里启动终端!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小惠珠哦/article/detail/927298
推荐阅读
相关标签
  

闽ICP备14008679号