当前位置:   article > 正文

ssh密钥对_sshqs

sshqs

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26

2. 发布公钥给服务器

ssh-copy-id -i ~/.ssh/id_rsa.pub yourname@hostname

# win
ssh-copy-id -i /c/Users/yourname/.ssh/id_rsa.pub yourname@hostname
#linux
ssh-copy-id -i ~/.ssh/id_rsa.pub yourname@hostname
  • 1
  • 2
  • 3
  • 4
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.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

vscode

远程ssh设置

vim /etc/ssh/sshd_config
# ADD#
# AllowTcpForwarding yes
/etc/init.d/ssh restart
  • 1
  • 2
  • 3
  • 4

阿里云主机断连

vim /etc/ssh/sshd_config
 
ClientAliveInterval 30
ClientAliveCountMax 86400
# #
# 1、客户端每隔多少秒向服务发送一个心跳数据

# 2、客户端多少秒没有相应,服务器自动断掉连接
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/492062
推荐阅读
相关标签
  

闽ICP备14008679号