Linux 下設置SSH 免密登陸,及相關報錯解決

目錄shell

一 環境centos

  1. 系統環境ssh

  2. 軟件環境ui

二 免密配置spa

  1.操做步驟code

   2. 配置失敗caseorm


一  環境ip

  1. 系統環境: CENTOS 6.6 內核 2.6.32ci

[xxx@scripts-1 ~]$ lsb_release -a
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 6.6 (Final)
Release:        6.6
Codename:       Final
[xxx@scripts-1 ~]$ cat /proc/version 
Linux version 2.6.32-504.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Oct 15 04:27:16 UTC 2014


  2. 軟件版本string

[xxx@scripts-1 ~]$ strings /usr/sbin/sshd |grep OpenSSH
OpenSSH_5.3p1-FC-0.9.3-104.el6
OpenSSH_5.3p1
OpenSSH_5.3
OpenSSH_2.3.0*
OpenSSH_2.3.*
OpenSSH_2.5.3*
OpenSSH_3.*
OpenSSH_4*
OpenSSH*
OpenSSH-2.0*,OpenSSH-2.1*,OpenSSH_2.1*,OpenSSH_2.2*
OpenSSH_2.5.0p1*,OpenSSH_2.5.1p1*
OpenSSH_2.5.0*,OpenSSH_2.5.1*,OpenSSH_2.5.2*
OpenSSH_2.*,OpenSSH_3.0*,OpenSSH_3.1*


二 免密配置

   1:目前有主機A 和主機B,但願從從主機A 能免密登陸到主機B 

  1. 1主機A 上生成 密鑰

[xxx@scripts-1 ~]$ ssh-keygen -t rsa

      查看主機A  當前用戶家目錄下 .ssh 目錄

   公鑰 在次文件裏 id_rsa.pub


    1.2 將A 主機公鑰 放到 B 主機家目錄 ./ssh 目錄authorized_keys 文件裏

   1.3 密鑰的配置完成

  2 失敗case

    此次作了不少主機的免密登陸,絕大多數 均可以避免密登陸,只有少數臺不能登陸。

    比對SSH 的配置文件作了比對,也是徹底同樣。

    以後分析到緣由 : 是被登陸的主機 用戶目錄權限的問題:

    1. 假設是B 主機,且免密登陸用戶名 爲test

    2. test 家目錄權限需爲 700 即 chmod 700 /home/test

    3. .ssh 目錄權限需爲700         chmod /home/test/.ssh

    4 authorized_keys  文件權限 需爲 600   chmod 600 /home/test/.ssh/authorized_keys

相關文章
相關標籤/搜索