Windows(Ubuntu)下GitBash生成public ssh key

   SSH目前是Unix和Linux上用于加密连接远程服务器的命令行工具。不仅是Windows用户将能够使用OpenSSH连接远程服务器,Windows系统本身也将运行一个服务来允许远程设备进行连接.

Windows

切换到C:\Users\<username>\.ssh

执行命令:ssh-keygen -t rsa -C "邮箱地址"
Generating public/private rsa key pair.
Enter file in which to save the key (//.ssh/id_rsa):
第一次生成由于没有id_rsa文件和id_rsa.pub文件,所以需要生成这两个文件,然后手动输入:./id_rsa
Enter file in which to save the key (//.ssh/id_rsa): ./id_rsa,虽然要求输入//.ssh/id_rsa,但这种方式不是在当前目录下
接下来两部是要求输入密码,不输入直接回车就完成了。

justbecause@DESKTOP-Q2PDR14 .ssh $  ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/justbecause/.ssh/id_rsa):  enter
Enter passphrase (empty for no passphrase):  enter
Enter same passphrase again:
Your identification has been saved in /c/Users/justbecause/.ssh/id_rsa.
Your public key has been saved in /c/Users/justbecause/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:6lguUfZeTIdIDfwt6cpArBQ5cuS+jWatOUYs0Cx9R7g  justbecause@DESKTOP-Q2PDR14
The key's randomart image is:
+---[RSA 2048]----+
|   ..o ..o       |
|  ..* . o .      |
| + o.* . o +     |
|o +.E * . * o    |
| o +.* .S+ o     |
|  . ==... +      |
|   o=.=+ o       |
|   o+B  +        |
|   .+oo          |
+----[SHA256]-----+
id_rsa  id_rsa.pub  known_hosts

C:\Users\yang\.SSH\id_rsa.pub
复制代码到:http://122.204.161.96:18099/profile/keys/42    Add SSH Key

Ubuntu 下解决办法

(1)      lyt@lyt-machine:~$  ssh-keygen -t rsa -C "yh_hzsd@163.com"
         Generating public/private rsa key pair.
         Enter file in which to save the key (/home/lyt/.ssh/id_rsa): 《Enter》
         Enter passphrase (empty for no passphrase): 
      【在ubuntu下以点开头命名的文件和文件夹是隐藏的, 进入自己主目录,按ctrl+h.就能看见以点号开头的隐藏文件, 有些文件因             为权限问题无法编辑,打开终端输入sudo  nautilus,会出现超级用户文件夹,就能编辑任何文件
(2)     然后将生成的id_rsa.pub的内容原封不动 复制代码到: http://122.204.161.96:18099/profile/keys/42     Add SSH Key  

         结果报错了:fatal: 'server' does not appear to be a git repository
                              fatal: Could not read from remote repository
         Please make sure you have the correct access rights
         and the repository exists.【百思不得其解,结果是  vi .git/config 没配置】
(3)      [core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
          [remote "origin"]

url =  git@122.204.161.96: yangheng/ccnu_edx.git
fetch = +refs/heads/*:refs/remotes/origin/*
           [remote " server "]  (此行是复制过来的)

url =  git@122.204.161.96:xuxiao/ccnu_edx.git
fetch = +refs/heads/*:refs/remotes/ server/*
           [branch "develop"]

remote = origin
merge = refs/heads/develop


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值