主頁 > 知識庫 > 安裝和配置OPENSSH

安裝和配置OPENSSH

熱門標(biāo)簽:沈陽藝匯通地圖標(biāo)注 騰訊美術(shù)館地圖標(biāo)注 孝感營銷電銷機器人源碼 鄭州智能外呼系統(tǒng)招商 ai電銷機器人自動篩選意向客戶 思茅地圖標(biāo)注app 智能電話機器人金融 AI電銷機器人PHP源碼 打電話機器人是什么軟件

OPENSSH的安裝和配置
一、 概述
傳統(tǒng)的遠(yuǎn)程網(wǎng)絡(luò)訪問服務(wù)在本質(zhì)上都是不安全的,因為它們在網(wǎng)絡(luò)上用明文傳送口令和數(shù)據(jù),很容易被截獲,其安全驗證方式也容受到中間人的攻擊。通過使用OPENSSH,你可以把所有傳輸?shù)臄?shù)據(jù)進(jìn)行加密。
SSH是由客戶端和服務(wù)端的軟件組成的,有兩個不兼容的版本分別是:1.x和2.x。它需要不同的客戶端。OPENSSH同時支持SSH1和SSH2。
二、 OPENSSH的安全驗證方式
OPENSSH提供兩種級別的驗證方式:
1、 基于口令的安全驗證:只要你知道服務(wù)器上的帳號和口令,那么你可以登錄到遠(yuǎn)程主機上??诹詈蛿?shù)據(jù)在傳輸過程中都會被加密。
2、 基于密鑰的安全驗證:采用此方式驗證你必須在遠(yuǎn)程服務(wù)器上為自己創(chuàng)建一對密鑰(不對稱密鑰對),把公有密鑰放在遠(yuǎn)程服務(wù)器上自己的宿主目錄中。而私有密鑰則由自己保存。
三、 所需軟件
openssl-0.9.5a.tar.gz 下載網(wǎng)址:http://www.openssl.org
openssh-2.5.2p2.tar.gz 下載網(wǎng)址:http://www.openssh.org
四、 安裝步驟
下面的安裝選項根據(jù)你自己的情況可適當(dāng)調(diào)整,如果有不明白的地方可以參考README、INSTALL文檔。此文環(huán)境假定所有源文件都在/var/tmp下:
4. 1安裝OPENSSL
[root@mail tmp]tar xzpf openssl-0.9.5a.tar.gz
[root@mail tmp]cd openssl-0.9.5a
[root@mail openssl-0.9.5a]./config –t
[root@mail openssl-0.9.5a]./config --prefix=/usr --openssldir=/etc/ssl
編輯Makefile.ssl文件更改MANDIR=$OPENSSL/man為MANDIR=/usr/man。
[root@mail openssl-0.9.5a]make
[root@mail openssl-0.9.5a]make test
[root@mail openssl-0.9.5a]make install
[root@mail openssl-0.9.5a]cd ..
[root@mail tmp]rm –rf openssl*
4.2 安裝OPENSSH
在安裝OPENSSL之前確認(rèn)你的系統(tǒng)中已安裝了zlib庫,可用下面的命令來檢查一下,若沒有不要的猶豫,它就在你的系統(tǒng)安裝光盤中,馬上安裝吧!
[root@mail tmp]rpm –qi zlib
[root@mail tmp]tar xzpf openssh-2.5.2p2.tar.gz
[root@mail openssh-2.5.2p2]./configure \
>--prefix=/usr \
>--sysconfdir=/etc/ssh \
>--with-tcp-wrappers \
>--with-ipv4-default \
>--with-ssl-dir=/usr/include/openssl
[root@mail openssh-2.5.2p2]make
[root@mail openssh-2.5.2p2]make install
[root@mail openssh-2.5.2p2]install –m 644 contrib/redhat/sshd.pam \
/etc/pam.d/sshd
[root@mail openssh-2.5.2p2]cd ..
[root@mail tmp]rm –rf openssh*
五、 配置OPENSSH
5.1 在inetd服務(wù)器中起動SSHD守護(hù)程序只需加入下面一行(建議在起動TELNET守護(hù)程序這一行更改,以完全代替TELNET):
ssh stream tcp nowait root /usr/sbin/tcpd sshd –I
5.2 SSH客戶端配置文件/etc/ssh/ssh_config,一般情況下我們在多使用WINDOWS平臺的客戶端,此配置文件只有客戶端不指定任何參數(shù)的情況下才使用,其內(nèi)容如下:
# $OpenBSD: ssh_config,v 1.9 2001/03/10 12:53:51 deraadt Exp $
Host *
ForwardAgent no
ForwardX11 no
RhostsAuthentication no
RhostsRSAAuthentication yes
RSAAuthentication yes
PasswordAuthentication no
FallBackToRsh no
UseRsh no
BatchMode no
CheckHostIP yes
StrictHostKeyChecking yes
IdentityFile ~/.ssh/identity
IdentityFile ~/.ssh/id_dsa
IdentityFile ~/.ssh/id_rsa1
IdentityFile ~/.ssh/id_rsa2
Port 22
Protocol 2,1
Cipher blowfish
EscapeChar ~

5.3 SSH服務(wù)器端配置文件/etc/ssh/sshd_config,關(guān)于下面各個參數(shù)的含義請參考使用手冊,此例中使用第二種認(rèn)證方式(基于密鑰的認(rèn)證)以提高安全性。
# $OpenBSD: sshd_config,v 1.34 2001/02/24 10:37:26 deraadt Exp $
Port 22
#Protocol 2,1
#ListenAddress 0.0.0.0
#ListenAddress ::
HostKey /etc/ssh/ssh_host_key
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
ServerKeyBits 768
LoginGraceTime 600
KeyRegenerationInterval 3600
PermitRootLogin without-password
#
# Don't read ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes
StrictModes yes
X11Forwarding no
X11DisplayOffset 10
PrintMotd yes
KeepAlive yes

# Logging
SyslogFacility AUTH
LogLevel INFO
#obsoletes QuietMode and FascistLogging

RhostsAuthentication no
#
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
RhostsRSAAuthentication no
#
RSAAuthentication yes

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication no
PermitEmptyPasswords no

# Comment to enable s/key passwords or PAM interactive authentication
# NB. Neither of these are compiled in by default. Please read the
# notes in the sshd(8) manpage before enabling this on a PAM system.
ChallengeResponseAuthentication no

# To change Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#AFSTokenPassing no
#KerberosTicketCleanup no

# Kerberos TGT Passing does only work with the AFS kaserver
#KerberosTgtPassing yes

#CheckMail yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net
#ReverseMappingCheck yes

#Subsystem sftp /usr/libexec/sftp-server

六、 生成認(rèn)證密鑰
當(dāng)采用密鑰認(rèn)證方式時,第個用戶在遠(yuǎn)程服務(wù)器上必須生成自己的密鑰;下面我們就以實例的方式敘述此過程:
6.1 為服務(wù)器上的用戶robin生成rsa1認(rèn)證密鑰:
[root@mail tmp]su robin
[root@mail tmp]ssh-keygen
此命令運行時將會提示你密鑰的存放位置,直接回車;在提示你輸入passphrase時建議你輸入一個不短于10個字符的英文句子,以防止你的私有密鑰被別人盜用。它會在當(dāng)前用戶的個人目錄個生成兩個文件:
~/.ssh/identify robin的私有密鑰
~./ssh/identify.pub robin的公用密鑰
6.2 不要忘記idnentify.pub更名:
[root@mail .ssh]mv identify.pub authorized_keys
6.3 拷貝文件到安全的地方,在服務(wù)器上你的宿主文件夾中刪除identify文件。
七、 使用PuTTY客戶端登錄
終于到檢驗我們工作結(jié)果的時候了,在WINDOWS平臺的SSH客戶端我推薦使用Putty,很好用,不像其它一些客戶端只支持基于口令的安全驗證;你可以在這里下載:
http://www.chiark.greenend.org.uk/~sgtatham/putty.html.
在連接服務(wù)器時不要忘記在connect->SSH中指定你的私有密鑰的存放位置,輸入創(chuàng)建密鑰時的passphrase,如果不出意外你就可以安全地行程控制你的服務(wù)器了。

標(biāo)簽:透傳 江蘇 淄博 和田 張掖 延安 臨汾 甘孜

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《安裝和配置OPENSSH》,本文關(guān)鍵詞  安裝,和,配置,OPENSSH,安裝,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《安裝和配置OPENSSH》相關(guān)的同類信息!
  • 本頁收集關(guān)于安裝和配置OPENSSH的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章