• Linux下制作不用密码可立即登录的SSH用户



    一、客户端建立两把钥匙

    (1)本例以客户端的monkey用户为例,首先切换到~/.ssh目录下,如果没有该目录的话,需要进行新建

    cd ~

    mkdir .ssh

    chmod 700 .ssh

    cd ~/.ssh

    (2)执行ssh-keygen命令生成客户端的公钥和私钥

    ssh-keygen

    [monkey@RHEL6 .ssh]$ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/monkey/.ssh/id_rsa): 
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /home/monkey/.ssh/id_rsa.
    Your public key has been saved in /home/monkey/.ssh/id_rsa.pub.
    The key fingerprint is:
    20:08:e7:d3:59:3a:13:ae:a2:7a:ce:6f:b2:59:ec:44 monkey@RHEL6.5
    The key's randomart image is:
    +--[ RSA 2048]----+
    |. . . .          |
    | + + =           |
    |  + O .          |
    |   o + .         |
    |. . E   S        |
    |.. o             |
    |.   +            |
    |..o=.            |
    |.o==o            |
    +-----------------+


    红色标记的为客户端的私钥,黄色标记的是服务端的公钥

    -rw------- 1 monkey monkey 1675 7月  25 01:12 id_rsa
    -rw-r--r-- 1 monkey monkey  396 7月  25 01:12 id_rsa.pub




    二、将公钥文件上传到服务器上

    例如,我们想登陆服务器192.168.1.100的iPanda用户,则需要将客户端的公钥上传到iPanda用户的家目录下

    scp  ~/.ssh/id_rsa.pub  iPanda@192.168.1.100:/~




    三、将公钥文件放置到服务器的正确目录与文件名

    新建~/.ssh目录(如果没有的话), 并追加文件到 .ssh/authorized_keys中

    mkdir .ssh

    chmod 700 .ssh

    将.id_rsa.pub中的数据追加到.ssh/authorized_keys文件中

    cat  id_rsa.pub >>  .ssh/authorized_keys

    chmod 644  .ssh/authorized_keys



  • 相关阅读:
    docker学习
    io性能调优之page cache
    ll命令执行后结果分析
    Angular2+ ViewChild & ViewChildren解析
    <router-outlet> 干什么用的?
    npm基本命令
    什么情况下会出现undefined
    关于VUE调用父实例($parent) 根实例 中的数据和方法
    vue中的this指向问题
    对 Foreach 的理解
  • 原文地址:https://www.cnblogs.com/xialiaoliao0911/p/7523926.html
Copyright © 2020-2023  润新知