• Linux下配置免密登录!


    ssh-keygen  产生公钥与私钥对.
    ssh-copy-id 将本机的公钥复制到远程机器的authorized_keys文件中,ssh-copy-id也能让你有到远程机器的home, ~./ssh , 和 ~/.ssh/authorized_keys的权利

    第一步:在本地机器上使用ssh-keygen产生公钥私钥对
    1. jsmith@local-host$ [Note: You are on local-host here]
    2. jsmith@local-host$ ssh-keygen
    3. Generating public/private rsa key pair.
    4. Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):[Enter key]
    5. Enter passphrase (empty for no passphrase): [Press enter key]
    6. Enter same passphrase again: [Pess enter key]
    7. Your identification has been saved in /home/jsmith/.ssh/id_rsa.
    8. Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub.
    9. The key fingerprint is:
    10. 33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9 jsmith@local-host
    第二步:用ssh-copy-id将公钥复制到远程机器中
    1. jsmith@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
    2. jsmith@remote-host's password:
    3. Now try logging into the machine, with "ssh 'remote-host'", and check in:
    4. .ssh/authorized_keys
    5. to make sure we haven't added extra keys that you weren't expecting.

    注意: ssh-copy-id 将key写到远程机器的 ~/ .ssh/authorized_key.文件中

    第三步: 登录到远程机器不用输入密码
    1. jsmith@local-host$ ssh remote-host
    2. Last login: Sun Nov 16 17:22:33 2008 from 192.168.1.2
    3. [Note: SSH did not ask for password.]
    4. jsmith@remote-host$ [Note: You are on remote-host here]

     

    另外:

    1. ssh-copy-id -u wyz -i ~/.ssh/id_rsa.pub wyz@remote_host

    上述是给wyz用户赋予无密码登陆的权利

  • 相关阅读:
    第四章 高级查询(二)
    部分 语法Mysql
    MySQL高级查询
    BZOJ 3124 SDOI2013 直径
    BZOJ 3130 SDOI2013 费用流
    BZOJ 3993 SDOI2015 星际战争
    BZOJ 3997 TJOI2015 组合数学
    BZOJ 4003 JLOI2015 城池攻占
    BZOJ 3925 ZJOI2015 地震后的幻想乡
    codeforces #313 div1 E
  • 原文地址:https://www.cnblogs.com/taomylife/p/8241792.html
Copyright © 2020-2023  润新知