Go to main content

手册页部分 1:用户命令

退出打印视图

更新时间: 2022年7月27日 星期三
 
 

remote_shell(1)

名称

rsh, remsh, remote_shell - 远程 shell

用法概要

rsh [-n] [-l username] hostname command
rsh hostname [-n] [-l username] command
remsh [-n] [-l username] hostname command
remsh hostname [-n] [-l username] command
hostname [-n] [-l username] command

描述


Caution

注意  -  All data exchanges over this protocol are performed without encryption, and have no protection against spoofing or snooping of traffic.The in.rshd server is disabled by default on Oracle Solaris and most other modern operating systems, and both the in.rshd server and the rsh command may be removed in future versions of Oracle Solaris.Use of the ssh(1) utility is strongly recommended instead.


rsh 实用程序会连接到指定的 hostname,并执行指定的 commandrsh 会将其标准输入复制到远程命令,将远程命令的标准输出复制到其标准输出,并将远程命令的标准错误复制到其标准错误。中断、退出和终止信号将传播到远程命令。rsh 通常在远程命令终止时终止。

如果省略了 command,而非执行单一命令,那么 rsh 将使用 rlogin(1) 登录远程主机。

rsh 不会返回 command 的退出状态代码。

不带引号的 Shell 元字符将在本地计算机上解释,而带引号的元字符将在远程计算机上解释。See EXAMPLES.

If there is no locale setting in the initialization file of the login shell (.profile, .cshrc, etc.) for a particular user, rsh always executes the command in the “C” locale instead of using the default locale of the remote machine.

选项

支持以下选项:

–l username

使用 username(而非本地用户名)作为远程用户名。如果未使用此选项,远程用户名将与本地用户名相同。

–n

rsh 的输入重定向到 /dev/null。有时需要使用此选项来避免 rsh 与调用它的 shell 之间的不良交互。For example, if you are running rsh and invoke a rsh in the background without redirecting its input away from the terminal, it blocks even if no reads are posted by the remote command.–n 选项可防止这一问题。

The type of remote shell (sh, csh, or other) is determined by the user's entry in the passwd(5) database on the remote system.

操作数

支持下列操作数:

command

要在指定的 hostname 上执行的命令。

用法

rshremsh 命令支持 IPv6。See ip6(4P).

Hostnames are provided by the hosts(5) name service.每台主机都有一个正式名称(数据库条目中的第一个名称),也可以有一个或多个别名。正式名称或别名都可以在 hostname 中指定。

如果执行 rsh 的初始文件名不是 rsh,则 rsh 将使用此名称作为其 hostname 参数。这可让您创建一个指向 rsh 的符号链接,当执行该链接时,将对该主机调用远程 shell。通过创建一个目录并使用常用主机名的符号链接进行填充,然后在 shell 搜索路径中包含该目录,可以运行 rsh(向 shell 中键入 hostname)。

如果使用基名 remsh 来调用 rsh,那么 rsh 将检查是否存在文件 /usr/bin/remsh。如果该文件存在,则 rsh 将像 remshrsh 的别名一样进行操作。如果 /usr/bin/remsh 不存在,那么 rsh 的操作行为就像 remsh 是主机名一样。

对于非安全 rsh 会话,每个远程计算机可拥有名为 /etc/hosts.equiv 的文件,其中包含一个与其共享用户名的可信主机的名称列表。在本地计算机和远程计算机上拥有相同用户名的用户可从远程计算机的 /etc/hosts.equiv 文件中所列的计算机执行 rsh 操作。Individual users can set up a similar private equivalence list with the file .rhosts in their home directories.此文件中的每一行都包含两个名称:主机名和用户名(用空格隔开)。The entry permits the user named username who is logged into hostname to use rsh to access the remote machine as the remote user.如果远程计算机上的 /etc/hosts.equiv 文件中不含该本地主机的名称,且远程用户的 .rhosts 文件中也不含该本地用户名和主机名,访问会被拒绝。/etc/hosts.equiv.rhosts 文件中所列的主机名必须为列在 hosts 数据库中的正式主机名;在这些文件中不能使用别名。

如果可信用户的帐户被锁定,则无法使用 rsh 以该可信用户的身份从可信主机登录。

如果远程计算机拒绝访问,rsh 不会提示输入口令,除非省略了 command 参数。

示例

示例 1 使用 rsh 附加文件

以下命令会将远程文件 lizard.file 从计算机 lizard 附加到计算机 example 上的文件 example.file

example% rsh lizard cat lizard.file >> example.file

以下命令会将计算机 lizard 上的文件 lizard.file 附加到文件 lizard.file2(也驻留在计算机 lizard 上)中:

example% rsh lizard cat lizard.file ">>" lizard.file2

退出状态

将返回以下退出值:

0

Successful completion.

1

An error occurred.

文件

/etc/hosts.equiv

可信的远程主机和用户

属性

有关下列属性的说明,请参见 attributes(7)

属性类型
属性值
可用性
network/legacy-remote-utilities
CSI
Enabled
Interface Stability
Obsolete

另请参见

rlogin(1), ssh(1), telnet(1), ip6(4P), hosts(5), hosts.equiv(5), attributes(7), in.rshd(8)

附注

将系统列在 hosts.equiv 中时,它必须具有与本地安全相当的安全性。将不安全的系统列在 hosts.equiv 中可能会危及整个系统的安全性。

You cannot run an interactive command, such as vi(1).Use ssh to start a remote login session if you wish to do this.

停止信号仅停止本地 rsh 进程。这无疑是错误的,但是目前很难修复,其原因过于复杂,以致于无法在此处加以解释。

不会将当前本地环境传递到远程 shell。

有时出于某些原因需要使用 –n 选项。例如,命令:

example% rsh somehost dd if=/dev/nrmt0 bs=20b | tar xvpBf −

将 shell 置于异常状态。很明显,tar 进程将在 rsh 进程之前终止。The rsh command then tries to write into the “broken pipe” and, instead of terminating neatly, proceeds to compete with your shell for its standard input.调用 rsh 时使用 –n 选项可避免此类事件。

此错误仅在 rsh 位于管道开头且未读取标准输入时出现。如果 rsh 实际上需要读取标准输入,请勿使用 –n 选项。For example:

example% tar cf − . | rsh sundial dd of=/dev/rmt0 obs=20b

不会产生该错误。如果您要在此类情形中使用 –n 选项,则 rsh 将错误地从 /dev/null(而非管道中)进行读取。

History

Support for Kerberos, including the options –a, –f, –F, –k, –K, –PN, –PO, and –x, was added in Solaris 10 3/05 and removed in Oracle Solaris 11.4.0.Prior to Solaris 10, a kerberized version was available in the Sun Enterprise Authentication Mechanism (SEAM) add-on package for Solaris.

Support for IPv6 was added in Solaris 8.

The rsh command, including support for the options –l and –n, has been present since the initial release of Solaris.