庞大资源库的计算机教程网站!
设为首页
加入收藏
总编信箱
投稿或申请专栏请先 [登 陆]
首页 操作系统 程序设计 图形图像 媒体动画 机械电子 WEB开发 数 据 库 办公系列 路由技术 网络原理 网络应用
认证考试 安全技术
首页>操作系统>Linux>安装经验>正文
资料搜索
Google搜索
Google
返回上级列表

推荐文章

快速保存网页中所有图片的方法
Windows中让光驱巧妙“隐身”技
防范非法用户入侵Win 2000/XP系
两款比较典型的ASP木马防范方法
有关表格边框的css语法整理
Windows XP中可以被禁用的服务
SQL Server导出导入数据方法
Javascript所有对象的属性的获
网页(HTML)中的特殊字符
与篮球共舞,尽显模式本色
QQ病毒的手工清除方法
Photoshop为极品美女打造性感睫
天衣无缝:IIS与PHP水火也相容
SQL Server存储过程编写和优化

OPENSSH的安装和配置

 作者:本站收集   日期:2005-3-13
字号选择〖 〗/ 双击滚屏 单击停止   
OPENSSH的安装和配置
一、 概述
传统的远程网络访问服务在本质上都是不安全的,因为它们在网络上用明文传送口令和数据,很容易被截获,其安全验证方式也容受到中间人的攻击。通过使用OPENSSH,你可以把所有传输的数据进行加密
SSH是由客户端和服务端的软件组成的,有两个不兼容的版本分别是:1.x和2.x。它需要不同的客户端。OPENSSH同时支持SSH1和SSH2。
二、 OPENSSH的安全验证方式
OPENSSH提供两种级别的验证方式:
1、 基于口令的安全验证:只要你知道服务器上的帐号和口令,那么你可以登录到远程主机上。口令和数据在传输过程中都会被加密
2、 基于密钥的安全验证:采用此方式验证你必须在远程服务器上为自己创建一对密钥(不对称密钥对),把公有密钥放在远程服务器上自己的宿主目录中。而私有密钥则由自己保存。
三、 所需软件
openssl-0.9.5a.tar.gz 下载网址:http://www.openssl.org
openssh-2.5.2p2.tar.gz 下载网址:http://www.openssh.org
四、 安装步骤
下面的安装选项根据你自己的情况可适当调整,如果有不明白的地方可以参考README、INSTALL文档。此文环境假定所有源文件都在/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之前确认你的系统中已安装了zlib库,可用下面的命令来检查一下,若没有不要的犹豫,它就在你的系统安装光盘中,马上安装吧!
[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服务器中起动SSHD守护程序只需加入下面一行(建议在起动TELNET守护程序这一行更改,以完全代替TELNET):
ssh stream tcp nowait root /usr/sbin/tcpd sshd –I
5.2 SSH客户端配置文件/etc/ssh/ssh_config,一般情况下我们在多使用WINDOWS平台的客户端,此配置文件只有客户端不指定任何参数的情况下才使用,其内容如下:
# $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服务器端配置文件/etc/ssh/sshd_config,关于下面各个参数的含义请参考使用手册,此例中使用第二种认证方式(基于密钥的认证)以提高安全性。
# $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

六、 生成认证密钥
当采用密钥认证方式时,第个用户在远程服务器上必须生成自己的密钥;下面我们就以实例的方式叙述此过程:
6.1 为服务器上的用户robin生成rsa1认证密钥:
[root@mail tmp]su robin
[root@mail tmp]ssh-keygen
此命令运行时将会提示你密钥的存放位置,直接回车;在提示你输入passphrase时建议你输入一个不短于10个字符的英文句子,以防止你的私有密钥被别人盗用。它会在当前用户的个人目录个生成两个文件:
~/.ssh/identify robin的私有密钥
~./ssh/identify.pub robin的公用密钥
6.2 不要忘记idnentify.pub更名:
[root@mail .ssh]mv identify.pub authorized_keys
6.3 拷贝文件到安全的地方,在服务器上你的宿主文件夹中删除identify文件。
七、 使用PuTTY客户端登录
终于到检验我们工作结果的时候了,在WINDOWS平台的SSH客户端我推荐使用Putty,很好用,不像其它一些客户端只支持基于口令的安全验证;你可以在这里下载:
http://www.chiark.greenend.org.uk/~sgtatham/putty.html.
在连接服务器时不要忘记在connect->SSH中指定你的私有密钥的存放位置,输入创建密钥时的passphrase,如果不出意外你就可以安全地行程控制你的服务器了。
上一篇:apache+php+mysql    下一篇:Sendmail配置终极指南  
[发送给好友]  [关闭窗口]  [返回顶部]   转载请注明来源:www.it00.com   
特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
责任编辑: 原点 投稿作者: 本站收集
信息来源: 网络 录入时间: 2005-3-13
关于我们 - 广告服务 - 版权申明 - 网站地图 - 联系方式 - 总编信箱 - 会员投稿