zoukankan      html  css  js  c++  java
  • 【Linux】服务器间免密登录、免确认机器指纹

    1.生成密钥

    ssh-keygen -t rsa -C "<填写自己方便识别的注释>" -b 4096  没什么问题就执行三次空格。 
    三次问题是1.填入生成密钥对的路径名字。2 填入自定义passphrsa。3确认。 

    静默模式,不需要回车生成密钥

    ssh-keygen -t rsa -N '' -f id_rsa -q 

    • -N:是指密码为空; 
    • -f:id_rsa是指保存文件为~/.ssh/id_rsa和~/.ssh/id_rsa.pub 
    • -q:指静默模式, 不输出显示
     1 [root@localhost home]# ssh-keygen -t rsa -C "********" -b 4096
     2 Generating public/private rsa key pair.
     3 Enter file in which to save the key (/root/.ssh/id_rsa): 
     4 Enter passphrase (empty for no passphrase): 
     5 Enter same passphrase again: 
     6 Your identification has been saved in /root/.ssh/id_rsa.
     7 Your public key has been saved in /root/.ssh/id_rsa.pub.
     8 The key fingerprint is:
     9 SHA256:oQYIN3KUkPmnCn0LrC25h5L0yVpiIvoHUgawDuyCKuE **************
    10 The key's randomart image is:
    11 +---[RSA 4096]----+
    12 |*==.             |
    13 |=*.o             |
    14 |o+. .   .        |
    15 |= + .. . .       |
    16 |+B o  o S        |
    17 |*o* ..           |
    18 |BEo=..           |
    19 |# =+o            |
    20 |+*o.             |
    21 +----[SHA256]-----+

    2.生成的公钥和私钥在/root/.ssh目录下

    1 [root@localhost .ssh]# pwd
    2 /root/.ssh
    3 [root@localhost .ssh]# ls -l
    4 总用量 12
    5 -rw-------. 1 root root 3247 9月  19 10:00 id_rsa       #私钥
    6 -rw-r--r--. 1 root root  746 9月  19 10:00 id_rsa.pub   #公钥
    7 -rw-r--r--. 1 root root  174 9月  18 16:58 known_hosts

    3.将公钥id_rsa.pub复制到远程主机/root/.ssh/文件中,并且重命名为authorized_keys。

    • scp  /root/.ssh/id_rsa.pub   root@远程ip:/root/.ssh/authorized_keys

    • ssh-copy-id  -i  ~/.ssh/id_rsa.pub root@远程ip

    验证密码即可

    4.连接

    • ssh 远程ip

    5.免确认机器指纹(不加入known_hosts)

    • ssh -o StrictHostKeyChecking=no 远程ip
  • 相关阅读:
    Python全栈开发:Mysql(二)
    Python全栈开发:pymysql
    Python全栈开发:html标签
    Pandas中Series和DataFrame的索引
    回归问题的性能度量标准
    偏度和峰度的计算
    特征相似性度量
    knn算法
    贝叶斯分类器
    线性模型和逻辑回归
  • 原文地址:https://www.cnblogs.com/jxd283465/p/11653899.html
Copyright © 2011-2022 走看看