频道直达 - 专题 - 新闻 - 技巧 - 组网 - 开发 - 安全 - web编程 - 图像 - 操作系统 - 数据库 - 教育 - 旅游 - 健康 - 时尚 - 驱动 - 软件 - 游戏 - 多媒体 - ERP - 讨论组

快速安装和配置OpenSSH

来源: 作者: 出处:巧巧读书 2006-09-18 进入讨论组

  下面我介绍在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来自:http://www.qqread.com/linux/2006/10/j234062.html 更多文章 更多内容请看Windows操作系统安装电脑配置手册服务器配置专栏专题,或进入讨论组讨论。
收藏此文】【 】【打印】【关闭
较早的文章:快速安装OOS

较新的文章:快速搞定D-Link530TX RevB网卡
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
巧巧读书宗旨
相关专题
最新论坛文章
站内各频道最新更新文档
站内最新制作专题
热门关键字导读
Photoshop教 程照片处理 照片制作 PS快捷键 抠图
计 算 机 故 障XP系统修复
艺 术 与 设 计设计 流媒体 设计欣赏 边框
计 算 机 安 全ARP
站内频道文章精选
巧巧电脑频道编辑信箱  告诉我们您想看的专题或文章