+ -
当前位置:首页 → 问答吧 → SSH_HOWTO中文文档。

SSH_HOWTO中文文档。

时间:2003-01-17

来源:互联网

前日配置**,望用ssh进行远程管理,

小弟对其配置虽有过经验却不很熟悉。

所以配置后,为了深化对其的了解程度,故找了几篇文档。

发现sshd也许太过简单,HowTo文档好像没什么通用的。

介绍mac上进行ssh Howto配置的实例不少。。

所以昨日闲余,译了这篇文档。小弟英文水平不高,难免出现笑话盼望各位大虾见谅。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~fleedib-litblue~~~

作者: fleedib   发布时间: 2003-01-17

SSH Howto

Herman Oosthuysen (赫尔曼.扼斯鲍森)

July 2002 (2002年7月)

System:Mandrake 8.1 系统:曼得瑞克 8.1(linux)


General 概要
The Secure Shell, is an incredibly powerful utility. It allows you to completely control one Unix machine from another. You can not only transfer files between computers securely, but you can execute programs remotely, with the screen display forwarded to the local machine, all the while being completely safe from eavesdroppers.
[ 安全壳,是一个难以置信地强大的工具。它允许你从一台Unix主机完全控另外一台。你只是不能在两台主机间安全的传递文件,但是你能远程的执行程序,用一个屏的显示传递到本地的主机,始终安全的回避掉窃听者(获取有效信息)。]

In effect, ssh makes your keyboard and monitor independent from the box it is connected to. You can be at home and work as if you are at your office, or the other way around. This is the ultimate telecommuting solution in one application and has been part of Unix for decades. While this sounds complex to a MS Windows user, working on multiple computers from a single terminal is as natural on a Unix system, as a penquin takes to water...
[ 安全壳有把你的键盘以及监视器封装起来(加密)建立连接的效果。你可以在家里像你在办公室里那样地工作,或者任何其他的地点。这是十年来远程办公解决方案的最终目标,并且已经以一个应用程序的形式存在于部分Unix系统中了。虽然这对于一个微软 Windows 用户听起来有些复杂,从一个终端工作在多台计算机上对于Unix系统是十分简单的事情,好像Penquin 适应水那样…. ]

When running applications on multiple machines, it can be difficult to remember what is running where, but KDE on Linux features multiple desktops (virtual screens). I usually use the first screens for the local machine and the last screens for the distant machine, to help keep my wits together.
[ 当在若干台机器上运行应用程序的时候,很难记住在哪运行的什么,但是Linux下的KDE的特性中的多重桌面(虚拟屏幕)。为了便于我的记忆,我经常为了本地机器而使用第一个屏幕,并且为远端的机器使用最后的一个屏幕。]
Installing and running the secure shell, should be dead simple. If it isn't, then you either have an old version or mis-matched versions at the two sites, or more likely you have a firewall or TCP Wrappers problem, preventing a connection from being established.
[ 安装并且运行安全壳通常是一件相当简单的事情。如果不是那样,那么要么是你是用了一个老的系统版本,要么是版本间存在着不匹配的问题,更多出现的在你的(Firewall)防火墙或者(TCP)访问控制协议地限制问题,禁止连接到目标连接。 ]
Note that there are many ssh versions: ssh1, ssh2 and openssh. That is apart from the commercial versions of ssh - ssh2 is preferred.
[ 关于安全壳的日志中有多种安全壳版本 Versions(版本): ssh1(安全壳版本1),ssh2(安全壳版本2),以及openssh开放安全壳。(openssh)是从商业版本的安全壳中分离出来的安全壳版本——安全壳版本2是首选! ]

Other howto guides explain how to get a connection up, but fail to give any trouble-shooting advice. Figuring out why it won't work can be a harrowing experience with secure systems, since NOT telling you what is wrong, is also a security requirement, since you don't want to make it easy for an intruder. This guide tries to fill this gap.

[ 另外一些HOWTO(怎么样做文档)至于怎样指导/解释怎么样建立一个连接,但是这里将给出一些关于故障排除的建议。定义出为什么它不工作当成一个使用安全系统的惨痛的经验,以后不用告诉你哪里出了错误,那也是安全的需求,从此你别想让入侵者对它感到容易。这篇指南可以可靠地填补上这些缺口。]

Configuration 配置
Do not change the default configuration files ssh_config or sshd_config until you have the basic setup working and even then, the default is probably OK for a home user, but not for a corporate user. See Batting Down the Hatches below.
[ 不要修改ssh_config或者 sshd_config地默认地配置直到你有基础的调整工作(经历),这个默认配置对于家庭用户来说或许还不错,但是对于法人团体来讲就不是一个好的主意了。见下文中的堵住缺口(Batting down the hatches) ]

Use the Control Centre, Services and stop the sshd daemon (or do killall sshd).
[ 使用 控制中心->服务,并且停止sshd 守护进程(或者杀掉所有的sshd进程。) ]

You must have the same user name on both systems, the server and the remote system. This keeps it easy.
[ 你必须在两个系统间有相同的用户名(译者补充:此处所指为用户的登陆id相同。),这里指的是服务器以及远端系统间。这使得配置(过程)简单化。]
Logged in as the required user, generate a set of RSA keys:
[ 使用你需要使用安全壳的用户进行登陆,生成一个RAS(加密算法)的密钥。]
.ssh-keygen -b 2048 -t rsa (译者注:生成基于RSA加密算法的长度为2048 位的密匙。)
.accept the defaults - don't enter a file name ( 接受默认不输入文件名字。译者补充,可以指定输入。)
.Passphrase: "whatever" (译者注:密码保护引号中的为密码内容。用于判断用户是否有使用密钥的权力。)

The following keys are generated in directory ~/.ssh:
[ 下列各项密匙已经生成在~/.ssh目录中。译者注:~/为unix系统中用户家路径的宏。]
.id_rsa (译注:这个为使用默认生成采用RSA加密算法的私有密匙的文件名。)
.id_rsa.pub (译注:这个为使用默认生成采用RSA加密算法的公有密匙的文件名。)

Copy the public key to authorized_keys to give you permission to log into the server from its own terminal: [复制这个公有密匙文件id_rsa.pub 成为文件authorized_keys给予它正确地登陆进入你的服务器的权限从它的终端中。]

.cd ~/.ssh (译补:进入~/.ssh目录。)
.cp id_rsa.pub authorized_keys (制作authorized_keys 文件为rsa.pub的副本。)

作者: fleedib   发布时间: 2003-01-17

Test 测试

Find your server IP address using ifconfig:
[ 使用命令ifconfig 获得你的服务器ip地址。 ]

./sbin/ifconfig -a

Restart sshd from Control Centre, Services. (or killall sshd and run it again).
[ 重新启动你的sshd服务从控制中心->服务。(或者杀掉所有sshd的进程,并且再次运行它们。) ]
Try to log into the server from its own terminal. If it doesn't work here, it won't work remotely:
[ 尝试从服务器它自己的终端登陆到自身。如果它不能工作,那么在远端也将如此。 ]

.ssh http://www.xxx.yyy.zzz (ssh 后面的为你的服务器自己的ip地址。)
.Enter passphrase for key '/home/user/.ssh/id_rsa': 'whatever' (输入你的密匙保护口令。)

If all went well, you'll be asked for your passphrase and after that you'll get a message like: Last login: time and date.
[ 如果一切都很正常,你将被询问过你的密匙保护口令以后取得像这样的信息:Last login:time and date 上次登陆的时间和日期。 ]

The very first time, you'll get a message like: Warning: Permanently added http://www.xxx.yyy.zzz to the list of known hosts.
[ 如果第一次这样做(译补:每次使用ssh到以前未曾尝试连接到的主机的时候,know_list列表中没有目标主机信息时候)你将看到这样的信息:永久地增加地址 http://www.xxx.yyy.zzz 到已知主机列表。]

After this, you'll get a new shell prompt and the shell will work as usual, except that it is now a ssh session. Type exit, to get back to a normal session.
[ 在这之后,你将得到一个新的壳的提示符并且可以像以往那样地工作。只不过现在它是一个安全壳的对话。]

Bubble, Bubble, Toil and Trouble 假设出现的辛苦/问题
If sshd is dead or unreachable, you will get the message: ssh: Connect to http://www.xxx.yyy.zzz port 22: Connection refused.
[ 如果安全壳守护进程不能工作或者(连接)不可到达,你将获得这样的信息:ssh:连接到 http://www.xxx.yyy.zzz 端口22连接被刷新。]

On a server with two ethernet cards, sshd will by default listen on both ethernet interfaces, on port 22. This is usually what you want.
[ 在一个服务器上使用两个以太网卡,安全壳守护进程将默认地在端口22监听每一块以太网卡。这通常是你所希望的。 ]

If you can't log in using the one IP address, try the other one.
[ 如果你不能登陆进这其中的一个IP地址,试试另一个。]
If the local interface works, but the external interface doesn't, the trouble lies with your firewall.
[ 如果本地的接口工作了,但是外部的接口不能工作,这个故障出现在你的防火墙上。 ]
Ensure that port 22 is open for TCP and UDP traffic:
[ 却保段口22 是开启状态,并且准许TCP 以及 UDP协议地通行:]

.iptables –L
will tell you what the firewall is doing. If required, modify the file /etc/rc.d/rc.firewall.

[ 命令iptables –L 将告诉你防火墙正在进行何种操作。如果需要,修改位于/etc/rc.d/rc.firewall 的文件。]

Add someting like the following rules: [color][ 增加一些像接下来做的那样的规则。 ][/color]

.iptables -A INPUT -i http://www.xxx.yyy.zzz -p tcp --dport 22 -j ACCEPT
.iptables -A INPUT -i http://www.xxx.yyy.zzz -p udp --dport 22 -j ACCEPT

to poke a hole for port 22 in the firewall. [ 在防火墙为端口22打开缺口。]

Restart the firewall and try to log in again: [ 重新启动防火墙,并且再次尝试连接。 ]

./rc.firewall

Confirm that the new rules are OK with iptables -L as before.
[ 在那以前使用命令iptables –L 确定新的规则的生效。]

TCP Wrappers 访问控制协议的封装
TCP Wrappers presents another layer of firewalling which you may have to reckon with.
[ TCP 封装为另一个层提供(防火墙过滤)可能你不得不自己去认真核对。]

If you have poked a hole in the iptables firewall and ssh still doesn't want to connect, edit the file /etc/hosts.allow and add the following line:

[ 如果你已经在防火墙上穿出个洞,并且安全壳依然不想连接,编辑位于/etc/hosts.allow 的文件在其中增加下面的一行. ]
.sshd: ALL
Now try again. This should be the last issue.
[ 现在再试一次。这将是最后的问题。 ]

Key Distribution 密匙发布

Once you can log in from the local terminal using the external ethernet interface IP address, generate and distribute the public keys so that the server has all the remote public keys in its authorized_keys file and try to log in from the remote.
[ 一旦你能从本地的终端使用外部的以太网接口的IP地址登陆,生成以及发布你的公共秘匙所以服务器有全部的公共密匙在文件authorized_keys 并且尝试从远处登陆。]
RSA keys of 2048 bits are recommended. This is secure as of the time of writing and should remain secure for the next five years or so, given the current rate of computer progress.
[ 基于RSA2048位加密算法的密匙是被推荐的。在给出当前计算机的发展状况的估计,从写这篇文章的时候起并且持续5年这将是安全的。]
Note that each public key is a single line, a very long one. Do not use an editor that will truncate or wrap the lines - vi to the rescue... well, I use gedit, do not use kate.
[ 注:每一个公共的密匙都是非常长的一行。不要使用一个editor编辑器,那将截去或者扭曲行(使行信息发生变化) – vi可以援救(修复)….好了,我使用gedit,不要使用kate。]

The ssh system only use the RSA public and private keys to authenticate the remote machines (to ensure that only valid users log in). Session keys for data transfer are generated automatically at regular intervals. The default encryption method used for data transfer is the Blowfish algorithm by Bruce Schneier, which is still known to be secure as of writing. The result is a very fast and secure link.
[ 安全壳系统只通过使用基于RSA加密算法的公共密匙以及私有密匙来鉴别远端主机(确保有效的用户登陆进入)。在正确地审核之后自动地建立使用了密匙加密为了数据传输对话。这默认地数据传输地加密算法是Bruce Schneier(布鲁斯.斯奈叶尔)所写的Blowfish(河豚)算法,那是个知名的安全作品。提供了安全并且十分快速的连接。]

Secure File Transfer Protocol 安全文件传输协议

Ssh2 offers sftp as a Subsystem. This is configured in the file /etc/ssh/sshd_config. The default install of the program sftp-server is in /usr/lib/ssh, but the program should be in the user path, to allow sshd to execute it. Look at the last line of the /etc/ssh/sshd_config file and modify it to read:
[ 安全壳版本2 建议使用sftp 作为一个子系统,这个配置文件位于/etc/ssh/sshd_config.默认的sftp-server(安全文件传输服务器)安装在/usr/lib/ssh中,但是这个程序将在用户的路径中为了安全壳的守护进程可以执行它。看位于/etc/ssh/sshd_config 文件的最后一行,读它并修改它。 ]

.Subsystem sftp /usr/bin/sftp-server (位于/etc/ssh/sshd_config的最后一行内容根据实际情况进行修改)

and make a link to it from /usr/bin: (并且为它(sftp-server)在/usr/bin中创建一链接)

.cd /usr/bin /*进入/usr/bin目录*/
.ln -s /usr/lib/ssh/sftp-server sftp-server /*为sftp-server在/usr/bin中创建链接*/

Now, you can use the sftp program or the gftp GUI program for secure ftp transfers. The gftp GUI program is recommended.
[ 现在你能使用安全文件传输程序(sftp)或者图形文件传输程序(gftp GUI)进行安全的文件传输了。这个(gftp GUI) 图形用户接口文件传输程序是被推荐使用的。 ]

Windows Clients Windows节点
Windows users can use the PuTTY program available from
http://www.chiark.greenend.org.uk/~sgtatham/putty/
for secure ftp or telnet access.
PuTTY is text based and runs in a DOS box - nothing fancy, but it gets the job done. It consists of a collection of small programs, to do telnet (not useful to windoze users), ftp (for file transfer) and key generation (for authentication).
[ Windows 用户为了安全的文件传输或者安全的telnet访问可以使用PuTTY程序,可以在
http://www.chiark.greenend.org.uk/~sgtatham/putty/ 中获得。PuTTY是一个运行于Dos下基于文本的平常的程序,但是它可以胜任这项工作。它由一些小的征集程序组成,为了telnet(对于windows用户不是很有用),ftp(为了文件传输。)以及密匙生成(为了(身份)鉴定/审核)。]
Basically, once you made and distributed your keys, you only need to run psftp. RSA keys of 2048 bits in size are recommended.
[ 基本上,一旦你制作并且发布了你的密匙,你只需要运行psftp.基于RSA加密算法的2048位加密密钥匙是被推荐的。]

Why PuTTY? Because it can be used to repair broken windows... ;-)
[ 为什么用PuTTY?因为它能于修补坏了的Windows。:-) ]

A Google search should yield many other possibilities, but it is best to start off with a simple client until you have your keys and IP addresses under control. Also, PuTTY is free of charge, while more fancy programs are anything but.
[ 一个 Google 搜索将提供更多的其他可能性,但是它对于一个简单的节点来说是最好的出发点。直到你有了可被你控制的密匙以及IP地址。同样,PuTTY是可以自由更改,虽然没有什么更多奇特的程序。]

The usual FTP commands work with PuTTY. Here is a brief list of the most frequently used commands:
[ 通常的FTP命令使用PuTTY来工作。这儿是一个最为经常使用的一个命令:]

.psftp http://www.xxx.yyy.zzz
.dir
.ls
.cd directoryname
.put filename
.get filename
.quit

If you only need to do occational file transfers, a simple FTP client like this is OK.
[ 如果你只需要去做一些像这样的文件传输,像这样的一个简单的FTP 客户端程序就不错。]

Batting Down the Hatches 堵住缺口

Once you are confident that the system works, examine the /etc/ssh/sshd_config file and disable simple password based log in. Also consider disabling root log in.
[ 一旦你确信系统工作了,检查文件/etc/ssh/sshd_config 并且禁止简单地基于密码(检验)的登陆。同时考虑禁止root(超级用户) 的登陆。]
Look for the following lines and change them to no: [找到下面列出的几行,并且更改他们到no(不准) ]

PasswordAuthentication no (译注:这里设置为no为此项为禁止简单的基于密码的检验登陆)
PermitRootLogin no (译注:这里禁止了超级用户基于安全壳的直接登陆)

To discourage trivial attacks following port scans, it is recommended that you do not use the default ssh port 22 for communication, but rather change it to something else, such as the now obsolete gopher port 70, or the defunct Napster port 6699, which will confuse your average script kiddie.
[ 为了拒绝检测琐细的攻击对于下列端口的检查,推荐你不使用默认的安全壳端口进行通讯,但是宁可更改它为一些别的东西,像这样(更改它为使用)陈旧的gopher 使用的70端口,或者已经停止使用的Napster 的端口6699,哪个将会混淆你的记录器。]

Log File 日志文件

You can monitor what the sshd daemon is doing by looking at the messages log file. Open a terminal as root and keep tail running:
[ 你可以从日志文件中监视你的安全壳守护进程(sshd)在做些什么。使用超级用户root运行终端,并且保证tail正在运行。]

tail -f /var/log/messages (使用tail –f 命令察看位于/var/log/message的信息内容。)

Don't bother trying to log in from a remote station, if you cannot do the same from the local machine's own keyboard...
[ 不要尝试从一个远端的工作站进行登陆,如果你不能在本地机器自己的键盘上做同样的事情….]

~~ 完

[ 时间仓促,难免犯错,望谅解 ]
译者:微蓝
于2003年1月16日

作者: fleedib   发布时间: 2003-01-17

小弟英文水平不高,望大家多包含
批评修改/补充可以来信flee@fescomail.net

此篇文档中所述,基于Mandrake Linux个别系统中的服务守护进程文件的位置以及部分脚本文件如firewall文件的位置会有所区别,请根据您系统实际状况酌情进行操作更改

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

作者: fleedib   发布时间: 2003-01-17

fleedib 兄 辛苦

文章已经拜读~~~~~~~~~~~

作者: eTony   发布时间: 2003-01-17

fleedib兄辛苦了。你既然对翻译有兴趣,能不能参与BLFS说明书的翻译校对工作?

作者: kj501   发布时间: 2003-01-17

收藏~~

作者: lits   发布时间: 2003-01-17

谢谢两位,刚才略微整理了一下,纠正了几处错误。

近日由于Yuking兄的小企鹅输入法,在我的机器极其上启动不正常。我使用winbook种类的键盘。
进行输入切换时候每当按ctrl + backspace时候X server 会自动重新启动。
在notebook 上的 rh 8以及台式极其中的suse都试验过。(望哪位指点一二)

我很困惑,所以为了输入方便输入中文文档,只得用notebook上的xp中的word完成这篇文档。

习惯用windows朋友如果需要可以下载副件。word的文件格式。doc?我不知道。

作者: fleedib   发布时间: 2003-01-17

ctrl + backspace ?
这本来就是Xserver的重启啊?

作者: tram   发布时间: 2003-01-17

谢谢team兄,我还真的不知道,见笑了。

http://www.linuxsir.com/bbs/showthre...threadid=19270
中的这句。看来是我误会了 ,该打,:o

3]注销当前用户,然后重启X服务器,在登录界面,按一下[CTRL]+ALT+[BACK SPACE],组合键,然后再进入桌面,小企鹅输入法就能用了。

现在正常,此句在my Notebook's Rh8 system中用fcitx打出,果然好用,快洁!超好用。看来以后我不会轻易换用输入法了。


作者: fleedib   发布时间: 2003-01-17

引用:
fleedib兄辛苦了。你既然对翻译有兴趣,能不能参与BLFS说明书的翻译校对工作?
kj501兄,谢谢小弟尽力为之。文档我下了。

team兄弟那篇术语参考够全啊。

其实我去了,而且注册了,不过你们把工作都包尽了:)

作者: fleedib   发布时间: 2003-01-18

GOOD!!!
精品!

fleedib兄辛苦了。。。。

作者: 北南南北   发布时间: 2003-05-06

热门下载

更多