落枫驿站

学艺术先扎根

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


阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/YangHeng816/article/details/52457096
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭