动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   服务器 → 阅读文章
  

 快速安装和配置OpenSSH

作者来源: 
阅读 数 254 人次 , 2006-4-5 4:22:00 

下面我介绍在RedHat上快速安装OpenSSH的经验。

你可以从
ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-2.3.0p1.tar.gz
下载到openssh,如果从别处下载,必须下载带有p1后缀的文件。
没有这个后缀的文件是OpenBSD专用的。

你还需要:
Zlib:
http://www.freesoftware.com/pub/infozip/zlib/
其实,你如果没有的话,那就是你没有在装RedHat时选择它。
现在还来得急,插入RedHat的CDROM,重启动,把zlib选上,就行了。

OpenSSL 0.9.5a or greater:
http://www.openssl.org/

我是弄的openssl-0.9.5-devel.rpm来安装的,比较方便,
而且我极力推荐这样做,因为后面的麻烦比较少。
ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/rpm/openssl-devel-0.9.5a-3.i386.rpm


下面,开始解包:
root@local# cd /usr/local/src
root@local# tar zxvf openssh-2.3.0p1.tar.gz
root@local# rpm -Uvh openssl-devel-0.9.5a-3.i386.rpm

搞定后,开始编译:
root@local# cd openssh-2.3.0p1
root@local# ./configure --prefix=/usr --sysconfdir=/etc/ssh \
--with-tcp-wrappers --with-ipv4-default \
--with-md5-passwords
root@local# make
root@local# make install
root@local# install -m644 contrib/redhat/sshd.pam /etc/pam.d/sshd
如果你已经用RedHat的安装盘装上了Zlib库,又已经把Openssl-devel
的rpm装好了,这个过程应该不会出错。(如果有,请告诉我,看我能不能解决)

如果一切顺利,那么:
root@local# cd ..
root@local# rm -rf openssh-2.3.0p1

下面生成主机密钥
root@local# ssh-keygen -b 1024 -f /etc/ssh/ssh_host_key -N ""
root@local# ssh-keygen -d -f /etc/ssh/ssh_host_dsa_key -N ""
如果这两步提示“已有文件存在”,那大胆覆盖好了。

下面的步骤比较重要,看清楚了!
编辑/etc/ssh/ssh_config,添加或改变下面的参数:
Host *
ForwardAgent no
ForwardX11 no
RhostsAuthentication no
RhostsRSAAuthentication no
RSAAuthentication yes
PasswordAuthentication yes
FallBackToRsh no
UseRsh no
BatchMode no
CheckHostIP yes
StrictHostKeyChecking no
IdentityFile ~/.ssh/identity
Port 22
Cipher blowfish
EscapeChar ~

编辑/etc/ssh/sshd_config,加入或改变下面的参数:
Port 22
ListenAddress 210.45.216.120
HostKey /etc/ssh/ssh_host_key
ServerKeyBits 1024
LoginGraceTime 600
KeyRegenerationInterval 3600
PermitRootLogin no
IgnoreRhosts yes
IgnoreUserKnownHosts yes
StrictModes yes
X11Forwarding no
PrintMotd yes
SyslogFacility AUTH
LogLevel INFO
RhostsAuthentication no
RhostsRSAAuthentication no
RSAAuthentication yes
PasswordAuthentication yes
PermitEmptyPasswords no


配置OpenSSH使其使用TCP-Wrappers inetd超级服务器
TCP-WRAPPERS用来启动和停止sshd1服务。当inetd运行的时候,
它会从配置文件/etc/inetd.conf中读入配置信息。
(在配置文件中每一行的不同项是用TAB或空格分开)

编辑“inetd.conf”文件(vi /etc/inetd.conf)并加入这一行:
ssh stream tcp nowait root /usr/sbin/tcpd sshd –i
(“-i”参数说明sshd是被inetd运行的)
怎么让这些生效呢?
本来是不用重起的,不过我觉得打命令更麻烦。
那好,
root@local# reboot



下面是SSH的用户配置
root@local# su foo
foo@local$ ssh-keygen
运行后会让你输入pass phrase,简单的说就是密码啦,
不过是加密密钥的密码,要记住它,以后可以用ssh-keygen -p改的。

然后会生成
/home/foo/.ssh/identity
/home/foo/.ssh/identity.pub
其中没有pub的是用户foo的私人密钥(要保护好),
有pub的是foo的公共密钥,要被ssh的客户程序使用。


把公用密匙identity.pub拷贝到远程机器的“/home/refoo/.ssh”目录下,
并改名为“authorized_keys”。当然,复制到哪个目录,取什么文件名,
取决于用什么ssh客户程序,这里我用openssh,后面我列举了两个windows
的ssh客户程序。

好了,下面你可以在远程机器上试试了(你得保证远程机器上装了openssh的客户程序。)
refoo@remote$ ssh -l foo local.domain.net


成功!



下面我列举两个Windows上的SSH客户软件
Putty
http://www.chiark.greenend.org.uk/~sgtatham/putty.html
TTSSH
http://www.zip.com.au/~roca/download.html
 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:Linux系统中Logcheck的安装和配置
· 下一篇:ipchains网卡设置菜鸟必读
· 循序渐进学习LINUX之软件配置
· 惠普06财年第一季度营收增长
· Linux内核编程实战经验谈
· 服务器存储典范:SCSI RAID
· Windows 2000 安全检查清单-初级篇


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077