openssh升級至7.2

此處升級操做的原則是保留系統原有ssh服務,新安裝高版本ssh服務html

一、下載openssh源碼包服務器

http://www.openssh.com/portable.htmlsession

二、安裝
#tar zxvf openssh-7.2p2.tar.gz
#cd openssh-7.2p2
#./configure --prefix=/usr/local/openssh --sysconfdir=/usr/local/openssh/etc --with-pam --with-ssl-dir=/usr/local/openssl --with-md5-passwords --mandir=/usr/share/man --with-zlib=/usr/local/zlib
#make && make install
三、配置啓動腳本和配置文件
cp /etc/init.d/sshd /ghca/bak/sshd #備份舊版sshd啓動腳本
cp /ghca/openssh-7.2p2/contrib/redhat/sshd.init /etc/init.d/sshd ##拷貝新版啓動腳本
vi /etc/init.d/sshd #編輯啓動腳本less

主要將如下內容ssh

SSHD=/usr/sbin/sshd
/usr/bin/ssh-keygen -A
/sbin/restorecon /etc/ssh/ssh_host_key.pub
/sbin/restorecon /etc/ssh/ssh_host_rsa_key.pub
/sbin/restorecon /etc/ssh/ssh_host_dsa_key.pub
/sbin/restorecon /etc/ssh/ssh_host_ecdsa_key.pub

修改成:spa

SSHD=/usr/local/openssh/sbin/sshd
/usr/local/openssh/bin/ssh-keygen -A
/sbin/restorecon /usr/local/openssh/etc/ssh_host_key.pub
/sbin/restorecon /usr/local/openssh/etc/ssh_host_rsa_key.pub
/sbin/restorecon /usr/local/openssh/etc/ssh_host_dsa_key.pub
/sbin/restorecon /usr/local/openssh/etc/ssh_host_ecdsa_key.pub

注意:此時/usr/local/openssh/etc目錄下可能沒有那幾個key,可是也能夠先這樣修改,具體這個幾個key的用法還沒作研究。rest

四、配置公私鑰文件
#cd /root/.ssh
#/usr/local/openssh/bin/ssh-keygen -t rsa  #生成公私鑰對
#cat id_rsa.pub >> authorized_keys  #寫入公鑰到服務器認證文件
五、將私鑰文件下載保存至本地
/root/.ssh/id_rsa
六、重啓sshd服務
/etc/init.d/sshd restart
七、配置本地SecureCRT並登陸服務器
將對應服務器登陸session配置中去掉密碼驗證,並配置公鑰路徑,以下圖:code

 

注意:openssh7.0之後就不容許root使用交互模式密碼登陸了,必須使用公鑰登陸,普通帳號可使用密碼方式登陸。htm

* The default for the sshd_config(5) PermitRootLogin option has
   changed from "yes" to "prohibit-password".
 * PermitRootLogin=without-password/prohibit-password now bans all
   interactive authentication methods, allowing only public-key,
   hostbased and GSSAPI authentication (previously it permitted
   keyboard-interactive and password-less authentication if those
   were enabled).

詳見:http://bluereader.org/article/66465824?qqdrsign=07af0blog

相關文章
相關標籤/搜索