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]-----+
justbecause@DESKTOP-Q2PDR14 .ssh $ ls
id_rsa id_rsa.pub known_hosts
justbecause@DESKTOP-Q2PDR14 .ssh $
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):
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,会出现超级用户文件夹,就能编辑任何文件】
结果报错了: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
[remote "origin"]filemode = truebare = falselogallrefupdates = true
url = git@122.204.161.96: yangheng/ccnu_edx.git
[remote " server "] (此行是复制过来的)fetch = +refs/heads/*:refs/remotes/origin/*
url = git@122.204.161.96:xuxiao/ccnu_edx.git
[branch "develop"]fetch = +refs/heads/*:refs/remotes/ server/*
remote = origin
merge = refs/heads/develop