同城约会| 杂志期刊| 小说| 两性论坛| 军事电影| 两性知识| 电脑知识| 汽车| 旅游| 收藏

Linux系统中OpenSSH的安装和配置之三

来源: 作者: 出处:综艺读书 2006-10-05 进入讨论组
关 键 词:系统管理  加密  word  windows  os  

  配置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运行的。在加入这一行后,通过发送一个SIGHUP信号(killall –HUP inetd)来更新“inetd.conf”文件。

[root@deep /root]? killall -HUP inetd

第二步

编辑“hosts.allow”文件(vi /etc/hosts.allow)并加入这一行:

sshd: 192.168.1.4 win.openarch.com

这一行表示IP地址为“192.168.1.4”,主机名为“win.openarch.com”的计算机允许用ssh访问服务器。

下面这些“daemon”字符串(用于TCP-WRAPPERS)被sshd1使用:

sshdfwd-X11 (允许/禁止X11转发).
sshdfwd-[port-number] (TCP转发).
sshdfwd-[port-name] (port-name在/etc/services中定义。用于TCP转发).

注意:如果准备使用ssh,一定要用在所有的服务器上。如果十台安全的服务器和一台不安全的服务器配在一起,也谈不上什么安全性。

更多的资料

如果想查找详细的资料可以用man命令查帮助页,读取相关信息:

$ man ssh (1) - OpenSSH secure shell client (remote login program)
$ man ssh [slogin] (1) - OpenSSH secure shell client (remote login program)
$ man ssh-add (1) - adds identities for the authentication agent
$ man ssh-agent (1) - authentication agent
$ man ssh-keygen (1) - authentication key generation
$ man sshd (8) - secure shell daemon

SSH1每用户配置

第一步

为本地服务器创建私有和公用密匙,执行下面的命令:

[root@deep]# su username
[username@deep]$ ssh-keygen1

举个例子,显示出来的结果可能是:

Initializing random number generator...
Generating p: ............................++ (distance 430)
Generating q: ......................++ (distance 456)
Computing the keys...
Testing the keys...
Key generation complete.
Enter file in which to save the key (/home/username/.ssh/identity): 【按下回车键】
Enter passphrase:
Enter the same passphrase again:
Your identification has been saved in /home/username/.ssh/identity.
Your public key is:
1024 37
14937757511251955533691120318477293862290049394715136511145806108870001764378494676831
29757784315853227236120610062314604405364871843677484233240919418480988907860997175244
46977589647127757030728779973708569993017043141563536333068888944038178461608592483844
590202154102756903055846534063365635584899765402181 username@deep.openarch.com
Your public key has been saved in /home/username/.ssh/identity.pub

注意:如果有多个帐号需要为每个帐号创建一个密匙。

你可能要为下面的服务器创建密匙:

l Mail服务器

l Web服务器

l 网关服务器

这允许对这些服务器进行有限的访问,例如,不允许用Mail服务器的帐号访问Web服务器或网关服务器。这样可以增加整体的安全性,即使因为某种原因有一个密匙被泄密了,也不会影响到其它的服务器。

第二步

把本机的公用密匙(identity.pub)拷贝到远程主机的“/home/username/.ssh”目录下,例如,使用“authorized_keys”这个名字。

注意:拷贝文件的一个方法使用ftp命令,另一个办法是把公用密匙用email(包含“~/.ssh/identity.pub”文件的内容)发给系统管理员。

改变pass-phrase

用加上“-p”参数的“ssh-keygen”命令,在任何时候都可以改变pass-phrase。用下面的命令,改变pass-phrase:

[root@deep]# su username
[username@deep]$ ssh-keygen1 –p

Enter file key is in (/home/username/.ssh/identity): [按下回车键]
Enter old passphrase:
Key has comment 'username@deep.openarch.com'
Enter new passphrase:
Enter the same passphrase again:
Your identification has been saved with the new passphrase.

OpenSSH用户工具

下面列出的是一些我们经常要用到的命令,当然还有很多其它的命令,更详细的信息可以查看man帮助页或其它文档。

ssh
ssh(Secure Shell)是用来登录远程计算机和在远程计算机上执行命令的程序。它是用来替代rlogin和rsh,以及在不安全的网络环境下在两台计算机之间提供安全和加密的信息交流。X11连接和TCP/IP端口可以被转发到一个安全的通道里。

用下面的命令,登录远程计算机:

[root@deep]# ssh [login_name] [hostname]

例如:

[root@deep]# ssh username www.openarch.com
username@deep.openarch.com's password:
Last login: Tue Oct 19 1999 18:13:00 -0400 from gate.openarch.com
Welcome to www.openarch.com on Deepforest.

[login_name]是用来登录ssh服务器的用户名,[hostname]是ssh服务器主机的地址。

scp
可以用这个命令把文件从本地计算机拷贝到远程计算机,或者反之,甚至可以在两台远程计算机之间用“scp”命令拷贝文件。把远程主机上的文件拷贝到当前目录的一个简单的方法如下。

用下面的命令把文件从远程主机拷贝到本地主机上:

[root@deep /]# su admin
[admin@deep /]$ scp -p [login_name@hostname]:/dir/for/file localdir/to/filelocation

例如:

[username@deep]$ scp -p username@mail:/etc/test1 /tmp
Enter passphrase for RSA key 'username@mail.openarch.com':
test1 | 2 KB | 2.0 kB/s | ETA: 00:00:00 | 100%

用下面的命令把文件从本地主机拷贝到远程主机上:

[root@deep /]# su admin
[admin@deep /]$ scp -p localdir/to/filelocation [username@hostname]:/dir/for/file

例如:

[username@deep]$ scp -p /usr/bin/test2 username@mail:/var/tmp
username@mail's password:
test2 | 7 KB | 7.9 kB/s | ETA: 00:00:00 | 100%

注意:“-p”选项表示文件的改变和访问时间属性以及权限,在拷贝过程中被保留。通常是需要这样的。

安装到系统中的文件

# /etc/ssh
# /etc/ssh/ssh_config
# /etc/ssh/sshd_config
# /etc/ssh_host_key
# /etc/ssh_host_key.pub
# /usr/bin/ssh
# /usr/bin/slogin
# /usr/man/man1/ssh.1
# /usr/man/man1/scp.1
# /usr/man/man1/ssh-add.1
# /usr/man/man1/ssh-agent.1
# /usr/man/man1/ssh-keygen.1
# /usr/bin/scp
# /usr/bin/ssh-add
# /usr/bin/ssh-agent
# /usr/bin/ssh-keygen
# /usr/man/man1/slogin.1
# /usr/man/man8/sshd.8
# /usr/sbin/sshd

Windows平台上免费的SSH客户软件

Putty
Putty的主页:http://www.chiark.greenend.org.uk/~sgtatham/putty.html

Tera Term Pro and TTSSH
Tera Term Pro的主页:http://hp.vector.co.jp/authors/VA002416/teraterm.html

TTSSH Homepage:http://www.zip.com.au/~roca/download.html

版权说明

这篇文章翻译和改编自Gerhard Mourani的《Securing and Optimizing Linux: RedHat Edition》,原文及其版权协议请参考:http://www.openna.com/。

中文版的版权属于作者brimmer 更多文章 更多内容请看Linux安全应用宝典  Linux安装  Linux安装专题,或进入讨论组讨论。
收藏此文】【 】【打印】【关闭
相关图文阅读
频道图文推荐
综艺读书宗旨
相关专题
·Windows操作系统安装 (12238篇文章)
·系统优化大全 (13944篇文章)
·数据库安装与卸载 (8978篇文章)
·Linux服务器的安全性能 (17195篇文章)
·揭秘Linux内存管理 (6897篇文章)
·解析Linux文件系统 (7080篇文章)
·Linux服务器 (11031篇文章)
·Linux系统实用教程 (6845篇文章)
·Linux安全应用宝典 (6845篇文章)
·Linux基础知识 (7124篇文章)
热点标签: 系统管理  加密  word  windows  os  
阅读排行榜
最新技术文档
站内各频道最新更新文档
站内最新制作专题
热门关键字导读
Photoshop教 程照片处理 照片制作 PS快捷键 抠图
计 算 机 故 障XP系统修复
艺 术 与 设 计设计 流媒体 设计欣赏 边框
计 算 机 安 全ARP
站内频道文章精选
百度推荐,商机无限
搜索您感兴趣的内容
Web 全站
综艺电脑频道编辑信箱  告诉我们您想看的专题或文章

Google

友情互链 | 收藏本站 | 联系我们 | 在线留言 | 京ICP备08008424号|