<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    大漠駝鈴

    置身浩瀚的沙漠,方向最為重要,希望此blog能向大漠駝鈴一樣,給我方向和指引。
    Java,Php,Shell,Python,服務(wù)器運(yùn)維,大數(shù)據(jù),SEO, 網(wǎng)站開(kāi)發(fā)、運(yùn)維,云服務(wù)技術(shù)支持,IM服務(wù)供應(yīng)商, FreeSwitch搭建,技術(shù)支持等. 技術(shù)討論QQ群:428622099
    隨筆 - 238, 文章 - 3, 評(píng)論 - 117, 引用 - 0
    數(shù)據(jù)加載中……

    Linux 使用公鑰登陸,拋棄密碼吧

    最近換上了MACBOOK PRO做開(kāi)發(fā),由于之前一直在WINDOWS下使用SSH客戶(hù)端,不用每次都輸入密碼,更換到MACOS后沒(méi)有好用的工具,最好用的還是Terminal, 因此想到配置SSH證書(shū)登錄。
    本地機(jī)器:MacOs
    遠(yuǎn)程服務(wù)器:CentOS 7
    一、本地生成公鑰和私鑰
    [user1@computer1]$ ssh-keygen -t rsa 
    Generating public/private rsa key pair. 
    Enter file in which to save the key (/home/user1/.ssh/id_rsa): 
    Created directory '/home/user1/.ssh'. 
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /home/user1/.ssh/id_rsa. 
    Your public key has been saved in /home/user1/.ssh/id_rsa.pub. 
    The key fingerprint is: 
    31:df:a5:73:4a:2f:a6:6c:1c:32:a2:f2:b3:c5:a7:1f user1@computer1
    在當(dāng)前用戶(hù)的.ssh目錄下生成了id_rsa, id_rsa.pub兩個(gè)文件。
    二、把公鑰復(fù)制到本地和服務(wù)器
    #sudo vim /etc/sshd_config
    設(shè)置
    RSAAuthentication yes
    PubkeyAuthentication yes

    # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
    # but this is overridden so installations will only check .ssh/authorized_keys
    AuthorizedKeysFile      .ssh/authorized_keys
    服務(wù)器端設(shè)置:
    scp ~/.ssh/id_rsa.pub server_user@ipaddress:/tmp
     
    cat /tmp/id_rsa.pub >> /home/server_user/.ssh/authorized_keys

    注:如果服務(wù)器端沒(méi)有,ssh目錄,需要單獨(dú)創(chuàng)建此目錄。
    三、設(shè)置權(quán)限和設(shè)置禁用密碼登錄
    服務(wù)器端權(quán)限配置
    chmod 700 .ssh
    chmod 640 .ssh/authorized_keys
    禁用服務(wù)器端密碼登錄

    vim /etc/ssh/sshd_config
    修改如下:
    修改PermitRootLogin,確認(rèn)AuthorizedKeysFile

    #LoginGraceTime
    PermitRootLogin without-password
    #StrictModes yes
    #MaxAuthTries 6
    #MaxSessions 10

    RSAAuthentication yes
    PubkeyAuthentication yes

    # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
    # but this is overridden so installations will only check .ssh/authorized_keys
    AuthorizedKeysFile      .ssh/authorized_keys
    重啟服務(wù)器SSH服務(wù)

    systemctl restart sshd
    ssh server_user@ipaddress
    無(wú)需密碼,直接登錄

    posted on 2015-09-22 11:40 草原上的駱駝 閱讀(3751) 評(píng)論(0)  編輯  收藏


    只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 精品无码免费专区毛片| 成年女人免费视频播放77777 | 亚洲精品免费在线| 在线视频免费观看www动漫| 一区二区三区免费视频播放器| 亚洲产国偷V产偷V自拍色戒 | 国产高清免费观看| 嫩草在线视频www免费观看| 亚洲国产午夜精品理论片在线播放 | 中文字幕久精品免费视频| 亚洲五月综合缴情婷婷| 国产日产亚洲系列最新| 蜜臀AV免费一区二区三区| 色吊丝免费观看网站| 亚洲精品第一国产综合精品| 又大又硬又爽免费视频| 69影院毛片免费观看视频在线| 亚洲AV无码之国产精品| 亚洲卡一卡2卡三卡4卡无卡三 | 亚洲第一页中文字幕| 亚洲国产精品综合久久一线| 亚洲黄色免费网站| free哆拍拍免费永久视频| 亚洲一区中文字幕在线电影网| 亚洲中文字幕在线乱码| 在线免费不卡视频| 中文字幕亚洲免费无线观看日本| 国产亚洲视频在线观看网址| 亚洲免费视频观看| 日韩亚洲人成在线综合日本| 亚洲国产精品专区在线观看| 毛片免费vip会员在线看| 国产色无码精品视频免费| 色婷婷精品免费视频| 亚洲日韩中文字幕一区| 麻豆亚洲AV永久无码精品久久| 久久久久亚洲AV综合波多野结衣 | 日韩精品亚洲人成在线观看| 亚洲一级黄色视频| 免费国产美女爽到喷出水来视频| 午夜国产精品免费观看|