我开发了一个工具使用JSch(用于与通过ssh其他机器进行通信的Java库)发送一个行命令,以不同的Linux机器在一杆
因此,我们的客户需要在所有机器上更改密码。 谷歌帮助我达到这一点:
echo -e "123\n123" | passwd username
echo -e "123\n123" | passwd username
如果“123”是新的密码。
该命令执行,但是这始终是输出:
[root@QNA-XR1 ~]# echo -e "123\n123" | passwd
Changing password for root
New password:
Retype password:
passwd: password for root is unchanged
这表明该命令没有成功。
请注意,这是在其上运行Linux的小型设备。 这是一个私人编译的版本,以尽可能紧凑。 我不知道很多关于Linux实际上!
这是机器的信息:
[root@QNA-XR1 ~]# uname -a
Linux QNA-XR1 2.6.22-XR100-v1.1.7 #1 Tue Aug 19 22:55:50 EDT 2008 ppc unknown
passwd的帮助:
[root@QNA-XR1 ~]# passwd --help
BusyBox v1.7.3 (2008-01-09 00:06:30 EST) multi-call binary
Usage: passwd [OPTION] [name]
Change a user password. If no name is specified,
changes the password for the current user.
Options:
-a Define which algorithm shall be used for the password
(choices: des, md5)
-d Delete the password for the specified user account
-l Locks (disables) the specified user account
-u Unlocks (re-enables) the specified user account
回声帮助
[root@QNA-XR1 ~]# help echo
echo: echo [-neE] [arg ...]
Output the ARGs. If -n is specified, the trailing newline is
suppressed. If the -e option is given, interpretation of the
following backslash-escaped characters is turned on:
\a alert (bell)
\b backspace
\c suppress trailing newline
\E escape character
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\\ backslash
\num the character whose ASCII code is NUM (octal).
You can explicitly turn off the interpretation of the above characters
with the -E option.
非常感谢提前对您有所帮助。