伺服器安全規範,伺服器規範

來源:互聯網
上載者:User

伺服器安全規範,伺服器規範

ssh 登入驗證:使用公開金鑰和Google認證

server 端 設定檔

Port 3208Protocol 2ListenAddress 0.0.0.0SyslogFacility AUTHPRIVRSAAuthentication yesPubkeyAuthentication yesPermitRootLogin noPermitEmptyPasswords noPasswordAuthentication yesChallengeResponseAuthentication noGSSAPIAuthentication no#是否在使用者退出登入後自動銷毀使用者憑證緩衝GSSAPICleanupCredentials yesUsePAM yesAcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGESAcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENTAcceptEnv LC_IDENTIFICATION LC_ALLX11Forwarding noUseDNS noClientAliveInterval 60Subsystem       sftp    /usr/libexec/openssh/sftp-server

  

client端設定檔

Port 3208Protocol 2ListenAddress ipSyslogFacility AUTHPRIVPermitRootLogin noPermitEmptyPasswords noPasswordAuthentication yesChallengeResponseAuthentication noGSSAPIAuthentication noGSSAPICleanupCredentials yesUsePAM yesAcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGESAcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENTAcceptEnv LC_IDENTIFICATION LC_ALLX11Forwarding noUseDNS noClientAliveInterval 60Subsystem       sftp    /usr/libexec/openssh/sftp-server

  

1.產生公開金鑰與私密金鑰

ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/home/client/.ssh/id_rsa): #此處直接按斷行符號即可Created directory '/home/client/.ssh'.Enter passphrase (empty for no passphrase): #此處直接按斷行符號即可Enter same passphrase again: #此處直接按斷行符號即可Your identification has been saved in /home/client/.ssh/id_rsa.Your public key has been saved in /home/client/.ssh/id_rsa.pub.

  

2. 將公開金鑰檔案追加到server端使用者目錄的./ssh/authorized_keys中 ,.ssh目錄許可權必須是0700
cat id_rsa.pub >> authorized_keyschmod 600 authorized_keys

  

3.server 端 和client 端 無密碼登入

scp ./id_rsa.pub sweet@192.168.1.101:/home/sweet/.ssh/authorized_keys#注意一下目標機的authorized_keys的許可權是-rw-r--r--,如果不是需要執行chmod 644 authorized_keys修改檔案的許可權

  

Google驗證器

安裝GOOGLE-AUTHENTICATOR驗證器1.安裝epel源rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm2.安裝git級二維碼工具yum install -y git qrencode3.安裝開發包工具yum groupinstall -y "Development Tools" pam-devel4.安裝google-authenticatorgit clone https://github.com/google/google-authenticator.gitcd google-authenticator/libpam/sh bootstrap.sh./configure && make && make installcp -v /usr/local/lib/security/pam_google_authenticator.so /lib64/security/5.產生基於計數的認證token(可以忽略時間錯誤)google-authenticator(n,y,y,y)6.更改ssh級pam設定## 修改PAMvi /etc/pam.d/sshdauth required pam_google_authenticator.so## 修改SSH配置ChallengeResponseAuthentication yesUsePAM yesservice sshd restart修改ssh的鑒權方式,改為鍵盤互動。注意: 這裡要把應急驗證碼記錄下,防止驗證壞掉以後無法登陸,也可以把ssh的公開金鑰下載下來做備用登陸方式

  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.