SSH密钥
1.生成ssh密钥对
不要私钥密码 连续回车 win git
ssh-keygen -t rsa -b 4096 -C "yourname or youremail""
qs@Dell MINGW64 ~/.ssh
$ ssh-keygen -t rsa -b 4096 -C "qs"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/qs/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/qs/.ssh/id_rsa
Your public key has been saved in /c/Users/qs/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:w+FK6G7tG7TCxhSPbD7j/o4FdUwg533xzFh5GCC9/Sc qs
The key's randomart image is:
+---[RSA 4096]----+
| . o.o.o.o+ |
| + + ..Bo . |
| . o = oo+. |
| . * + o. . |
| B + S . |
| B + o . E .|
| X.= o |
| +.*.. |
| o=+=. |
+----[SHA256]-----+
qs@Dell MINGW64 ~/.ssh
$ ls
id_rsa id_rsa.pub
2. 发布公钥给服务器
ssh-copy-id -i ~/.ssh/id_rsa.pub yourname@hostname
ssh-copy-id -i /c/Users/yourname/.ssh/id_rsa.pub yourname@hostname
ssh-copy-id -i ~/.ssh/id_rsa.pub yourname@hostname
qs@Dell MINGW64 ~/.ssh
$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@10.0.0.5
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/c/Users/qs/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@10.0.0.5's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@10.0.0.5'"
and check to make sure that only the key(s) you wanted were added.
vscode
远程ssh设置
vim /etc/ssh/sshd_config
# ADD#
# AllowTcpForwarding yes
/etc/init.d/ssh restart
阿里云主机断连
vim /etc/ssh/sshd_config
ClientAliveInterval 30
ClientAliveCountMax 86400
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)