zoukankan      html  css  js  c++  java
  • 配置通过密钥连接ssh

    1.首先在服务器上制作密钥对。首先用密码登录到你打算使用密钥登录的账户,然后执行以下命令:

    [root@host ~]$ ssh-keygen <== 建立密钥对
    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa): <== 按 Enter
    Created directory '/root/.ssh'.
    Enter passphrase (empty for no passphrase): <== 输入密钥锁码,或直接按 Enter 留空
    Enter same passphrase again: <== 再输入一遍密钥锁码
    Your identification has been saved in /root/.ssh/id_rsa. <== 私钥
    Your public key has been saved in /root/.ssh/id_rsa.pub. <== 公钥
    The key fingerprint is:

    密钥锁码在使用私钥时必须输入,这样就可以保护私钥不被盗用。当然,也可以留空,实现无密码登录。

    现在,在 root 用户的家目录中生成了一个 .ssh 的隐藏目录,内含两个密钥文件。id_rsa 为私钥,id_rsa.pub 为公钥。
    2. 在服务器上安装公钥

    键入以下命令,在服务器上安装公钥:

    [root@host ~]$ cd .ssh
    [root@host .ssh]$ cat id_rsa.pub >> authorized_keys

    3.如此便完成了公钥的安装。为了确保连接成功,请保证以下文件权限正确:

    [root@host .ssh]$ chmod 600 authorized_keys
    [root@host .ssh]$ chmod 700 ~/.ssh
  • 相关阅读:
    ZJOI2019爆蛋记
    NOIp2018退役记
    拓展中国剩余定理(exCRT)摘要
    FFT(快速傅里叶变换)摘要
    主席树摘要
    LCT摘要
    替罪羊树摘要
    FHQ Treap摘要
    逻辑回归1-逻辑回归原理详解
    NLP自然语言处理原理及名词介绍
  • 原文地址:https://www.cnblogs.com/ExzaiTin/p/8796811.html
Copyright © 2011-2022 走看看