当前位置首页 > Debian知识

Debian下配置SSH服务器的方法

阅读次数:297 次  来源:admin  发布时间:

Debian 503版本中实现的,Debian默认好像是没有ssh支持的。

SSH的安装

apt-get install openssh-server

apt-get install ssh

SSH的配置

OpenSSH的配置都集中在/etc/ssh/ssh_config文件中

编辑“ssh_config”文件(vim /etc/ssh/ssh_config),添加或改变下面的参数:

# Site-wide defaults for various optio

Host *

ForwardAgent no

ForwardX11 no

RhostsAuthentication no

RhostsRSAAuthentication no

RSAAuthentication ye

PasswordAuthentication ye

FallBackToRsh no

UseRsh no

BatchMode no

CheckHostIP ye

StrictHostKeyChecking no

IdentityFile ~/.ssh/identity

Port 22

Cipher blowfish

EscapeChar ~

下面逐行说明上面的选项设置: www.111cn.net

Host *

选项“Host”只对能够匹配后面字串的计算机有效。“*”表示所有的计算机。

ForwardAgent no

“ForwardAgent”设置连接是否经过验证代理(如果存在)转发给远程计算机。

ForwardX11 no

“ForwardX11”设置X11连接是否被自动重定向到安全的通道和显示集(DISPLAY set)。

RhostsAuthentication no

“RhostsAuthentication”设置是否使用基于rhosts的安全验证。

RhostsRSAAuthentication no

“RhostsRSAAuthentication”设置是否使用用RSA算法的基于rhosts的安全验证。

RSAAuthentication ye

“RSAAuthentication”设置是否使用RSA算法进行安全验证。

PasswordAuthentication ye

“PasswordAuthentication”设置是否使用口令验证。

FallBackToRsh no

“FallBackToRsh”设置如果用ssh连接出现错误是否自动使用rsh。

UseRsh no

“UseRsh”设置是否在这台计算机上使用“rlogin/rsh”。

BatchMode no

“BatchMode”如果设为“yes”,passphrase/password(交互式输入口令)的提示将被禁止。当不能交互式输入口令的时候,这个选项对脚本文件和批处理任务十分有用。

CheckHostIP ye

“CheckHostIP”设置ssh是否查看连接到服务器的主机的IP地址以防止DNS欺骗。建议设置为“yes”。

StrictHostKeyChecking no

“StrictHostKeyChecking”如果设置成“yes”,ssh就不会自动把计算机的密匙加入“$HOME/.ssh/known_hosts”文件,并且一旦计算机的密匙发生了变化,就拒绝连接。

SSH

#服务器端配置 /etc/ssh/sshd_config

#只考虑协议版本2

#全局配置

VersionAddendum TecZm-20050505 #在telnet ip 22时只能看出openssh的版本,看不出OS

Protocol 2 #使用协议版本2

Port 22 #sshd监听22端口

ListenAddress 192.168.7.1 #sshd只监听目标ip为192.168.7.1的请求

AllowGroups wheel myguest #允许wheel组和myguest组的用户登录

AllowUsers teczm authen@192.168.8.5 #允许来自以上组的teczm用户和authen用户登录,

#且authen用户只能从主机192.168.8.5登录

#DenyGroups #拒绝登录的组,参数设置和AllowGroups一样

#DenyUsers #拒绝登录的用户,参数设置和AllowUsers一样

#AllowTcpForwarding yes #是否转发的TCP包都被允许。默认是 “yes”。

LoginGraceTime 60 #60秒内客户端不能登录即登录超时,sshd切断连接。

KeyRegenerationInterval 1800 #1800秒(30分钟)后自动重新生成服务器的密匙。

MaxStartups 3 #设置同时发生的未验证的并发量,即同时可以有几个

UseDNS no #不使用DNS查询客户端。

PermitRootLogin no #不允许root登录,root可由wheel组用户登录后su。

X11Forwarding no #禁止用户运行远程主机上的X程序,我没有X,所以无所谓。

UseLogin yes #禁止X11Forwarding

#认证配置(口令认证、PAM认证、非对称密钥认证任选其一)

#口令认证

PubkeyAuthentication no #不使用非对称密钥认证

PasswordAuthentication yes #使用口令认证

PermitEmptyPasswords no #不允许使用空密码的用户登录

#PAM认证

PasswordAuthentication no #不使用口令认证

UsePAM #使用pam认证

ChallengeResponseAuthentication yes #允许挑战应答方式

#非对称密钥认证

PasswordAuthentication no #不使用口令认证

PubkeyAuthentication yes #使用非对称密钥认证

AuthorizedKeysFile .ssh/authorized_keys #用户认证使用的公钥。

更多详细内容请查看:http://www.111cn.net/sys/linux/57339.htm

上一篇:linux下开启https
下一篇:libxml2在ubuntu的安装和使用