zoukankan      html  css  js  c++  java
  • Linux上SSH登录远程服务器免密码

      在本地的客户端SSH到远程服务端时,每次都要输入用户名和密码,如果不想每次都输入密码则可以使用以下操作。

      首先在本地的客户端输入 ssh-keygen

    [keysystem@localhost ~]$ ssh-keygen 
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/keysystem/.ssh/id_rsa): 
    Created directory '/home/keysystem/.ssh'.
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /home/keysystem/.ssh/id_rsa.
    Your public key has been saved in /home/keysystem/.ssh/id_rsa.pub.
    The key fingerprint is:
    af:a4:d5:4d:96:3c:24:71:ea:37:47:0c:51:3b:ba:2b keysystem@localhost.localdomain
    The key's randomart image is:
    +--[ RSA 2048]----+
    |          . +o.  |
    |           + o . |
    |          o . =  |
    |         . + + . |
    |        S . X .  |
    |         o = =   |
    |        o o o    |
    |       + .E  .   |
    |      . .  ..    |
    +-----------------+
    [keysystem@localhost ~]$ 

    生成公私钥对,可以进入到~/.ssh目录下查看生成的公私钥对。

    [keysystem@localhost ~]$ cd ~/.ssh/
    [keysystem@localhost .ssh]$ ll -rlt
    total 8
    -rw-r--r--. 1 keysystem keysystem  413 Dec  4 22:12 id_rsa.pub
    -rw-------. 1 keysystem keysystem 1675 Dec  4 22:12 id_rsa
    [keysystem@localhost .ssh]$ 

    然后执行 ssh-copy-id dzy@172.20.16.42,其中dzy为远程主机的用户名,172.20.16.42为远程服务器的IP地址。

    [keysystem@localhost ~]$ ssh-copy-id dzy@172.20.14.42
  • 相关阅读:
    CentOS安装KDE
    __builtin_expect — 分支预测优化
    Linux中CPU亲和性(affinity)
    字节序
    gethostbyname
    字符串搜索算法
    排序算法
    Linux下使用http协议下载文件
    POSIX Timer
    POSIX-Data Structure
  • 原文地址:https://www.cnblogs.com/alsodzy/p/7979299.html
Copyright © 2011-2022 走看看