第06章openSSH服务器配置

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

配置OpenSSH服务器1.OpenSSH简介OpenSSH是SSH(SecureSHell)协议的免费开源实现用安全、加密的网络连接工具代替了telnet、ftp、rlogin、rsh和rcp工具OpenSSH支持SSH协议的版本1.3、1.5、和2OpenSSH的版本2.9以来,默认的协议是版本2,该协议默认使用RSA钥匙1.OpenSSH简介使用OpenSSH工具将会增进你的系统安全性使用OpenSSH工具的通讯,包括口令,都会被加密telnet和ftp使用纯文本口令,并被明文发送OpenSSH自动把DISPLAY变量转发给客户机器2.配置OpenSSH服务器openssh-server软件包和openssh软件包的安装OpenSSH守护进程使用/etc/ssh/sshd_config配置文件启动OpenSSH服务,使用/sbin/servicesshdstart命令停止OpenSSH服务器,使用/sbin/servicesshdstop命令2.配置OpenSSH服务器安装openSSL[root@mailtmp]tarxzpfopenssl-0.9.5a.tar.gz[root@mailtmp]cdopenssl-0.9.5a[root@mailopenssl-0.9.5a]./config–t[root@mailopenssl-0.9.5a]./config--prefix=/usr--openssldir=/etc/ssl编辑Makefile.ssl文件更改MANDIR=$OPENSSL/man为MANDIR=/usr/man2.配置OpenSSH服务器[root@mailopenssl-0.9.5a]make[root@mailopenssl-0.9.5a]maketest[root@mailopenssl-0.9.5a]makeinstall[root@mailopenssl-0.9.5a]cd..[root@mailtmp]rm–rfopenssl2.配置OpenSSH服务器安装openSSH在安装OPENSSL之前确认你的系统中已安装了zlib库,可用下面的命令来检查一下[root@mailtmp]rpm–qizlib2.配置OpenSSH服务器[root@mailtmp]tarxzpfopenssh-2.5.2p2.tar.gz[root@mailopenssh-2.5.2p2]./configure\--prefix=/usr\--sysconfdir=/etc/ssh\--with-tcp-wrappers\--with-ipv4-default\--with-ssl-dir=/usr/include/openssl[root@mailopenssh-2.5.2p2]make[root@mailopenssh-2.5.2p2]makeinstall[root@mailopenssh-2.5.2p2]install–m644contrib/redhat/sshd.pam\/etc/pam.d/sshd[root@mailopenssh-2.5.2p2]cd..[root@mailtmp]rm–rfopenssh2.配置OpenSSH服务器配置OPENSSH在inetd服务器中起动SSHD守护程序只需加入下面一行(建议在起动TELNET守护程序这一行更改,以完全代替TELNET)sshstreamtcpnowaitroot/usr/sbin/tcpdsshd–I2.配置OpenSSH服务器SSH客户端配置文件/etc/ssh/ssh_config,一般情况下我们多使用WINDOWS平台的客户端,此配置文件只有客户端不指定任何参数的情况下才使用2.配置OpenSSH服务器SSH服务器端配置文件/etc/ssh/sshd_config,这里使用了基于密钥的认证方式#$OpenBSD:sshd_config,v1.342001/02/2410:37:26deraadtExp$Port22#Protocol2,1#ListenAddress0.0.0.0#ListenAddress::HostKey/etc/ssh/ssh_host_keyHostKey/etc/ssh/ssh_host_rsa_keyHostKey/etc/ssh/ssh_host_dsa_keyServerKeyBits768LoginGraceTime600KeyRegenerationInterval3600PermitRootLoginwithout-password##Don'tread~/.rhostsand~/.shostsfilesIgnoreRhostsyes#Uncommentifyoudon'ttrust~/.ssh/known_hostsforRhostsRSAAuthentication#IgnoreUserKnownHostsyesStrictModesyesX11ForwardingnoX11DisplayOffset10PrintMotdyesKeepAliveyes2.配置OpenSSH服务器#LoggingSyslogFacilityAUTHLogLevelINFO#obsoletesQuietModeandFascistLoggingRhostsAuthenticationno##Forthistoworkyouwillalsoneedhostkeysin/etc/ssh/ssh_known_hostsRhostsRSAAuthenticationno#RSAAuthenticationyes#Todisabletunneledcleartextpasswords,changetonohere!PasswordAuthenticationnoPermitEmptyPasswordsno#Commenttoenables/keypasswordsorPAMinteractiveauthentication#NB.Neitherofthesearecompiledinbydefault.Pleasereadthe#notesinthesshd(8)manpagebeforeenablingthisonaPAMsystem.ChallengeResponseAuthenticationno#TochangeKerberosoptions#KerberosAuthenticationno#KerberosOrLocalPasswdyes#AFSTokenPassingno#KerberosTicketCleanupno2.配置OpenSSH服务器#KerberosTGTPassingdoesonlyworkwiththeAFSkaserver#KerberosTgtPassingyes#CheckMailyes#UseLoginno#MaxStartups10:30:60#Banner/etc/issue.net#ReverseMappingCheckyes#Subsystemsftp/usr/libexec/sftp-server2.配置OpenSSH服务器如果你重新安装了RedHatLinux系统,任何在它被重装前使用OpenSSH工具连接到这个系统上的客户在它被重装后将会看到下列消息重装后的系统会为自己创建一组新的身份标识钥匙;因此客户会看到RSA主机钥匙改变的警告2.配置OpenSSH服务器如果你想保存系统原有的主机钥匙,备份/etc/ssh/ssh_host*key*文件,然后在系统重装后恢复它当客户机在该系统重装后试图连接它,它们就不会看到以上的警告信息3.认证密钥生成认证密钥当采用密钥认证方式时,第一个用户在远程服务器上必须生成自己的密钥为服务器上的用户robin生成rsa1认证密钥[root@mailtmp]surobin[root@mailtmp]ssh-keygen3.认证密钥此命令运行时将会提示你密钥的存放位置,直接回车在提示你输入passphrase时建议你输入一个不短于10个字符的英文句子,以防止你的私有密钥被别人盗用会在当前用户的个人目录个生成两个文件~/.ssh/identifyrobin的私有密钥~./ssh/identify.pubrobin的公用密钥3.认证密钥idnentify.pub更名[root@mail.ssh]mvidentify.pubauthorized_keys4.客户端连接拷贝文件到安全的地方,在服务器上你的宿主文件夹中删除identify文件使用PuTTY客户端登录在WINDOWS平台的SSH客户端推荐使用Putty在connect-SSH中指定你的私有密钥的存放位置

1 / 19
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功