快速安装和配置OpenSSH

  下面我介绍在RedHat上快速安装OpenSSH的经验。 你可以从 ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-2.3.0p1.tar.gz 下载到openssh,如果从别处下载,必须下载带有p1后缀的文件。 没有这个后缀的文件是OpenBSD专用的。 你还需要: Zlib: 其实,你如果没有的话,,那就是你没有在装RedHat时选择它。 现在还来得急,插入RedHat的CDROM,重启动,把zlib选上,就行了。 OpenSSL 0.9.5a or greater: 我是弄的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 ~sgtatham/putty.html TTSSH ~roca/download.html 『 不可能 』只存在於蠢人的字典里

快速安装和配置OpenSSH

相关文章:

你感兴趣的文章:

标签云: