Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Trying to change an accounts password on a remote server.

1,244 views
Skip to first unread message

jgonz...@gmail.com

unread,
Feb 21, 2013, 2:26:20 PM2/21/13
to
I create a script to create an account on a remote server that does not let you log into the server with the root account. I was able to create the account but I have not been able to put in a password for the account I created. I then just took the command su - root -c "echo -e "Ch9ng3m3\nCh9ng3m3\n" | passwd joh" out of the script and ran it on the remote server locally command line on the server and it still does not work. When I log in as root and run the command echo -e "Ch9ng3m3\nCh9ng3m3\n" | passwd joh it does work.

jgonz...@gmail.com

unread,
Feb 21, 2013, 2:30:32 PM2/21/13
to
On Thursday, February 21, 2013 11:26:20 AM UTC-8, jgonz...@gmail.com wrote:
> I create a script to create an account on a remote server that does not let you log into the server with the root account. I was able to create the account but I have not been able to put in a password for the account I created. I then just took the command su - root -c "echo -e "Ch9ng3m3\nCh9ng3m3\n" | passwd joh" out of the script and ran it on the remote server locally command line on the server and it still does not work. When I log in as root and run the command echo -e "Ch9ng3m3\nCh9ng3m3\n" | passwd joh it does work.

I forgot to show the error I am getting. The builds account run root commands on the server.

$ id
uid=500(builds) gid=501(builds) groups=501(builds),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
$ su - root -c "echo -e "Ch9ng3m3\nCh9ng3m3\n" | passwd joh"
Changing password for user joh.
New password: Retype new password: Password change aborted.
New password: Password change aborted.
New password: Password change aborted.
passwd: Have exhausted maximum number of retries for service
$

Bill Marcum

unread,
Feb 21, 2013, 5:08:28 PM2/21/13
to
The su command with the pipe doesn't work because the command on the
right side of the pipe runs as a regular user, and a regular user can't
change another user's password.

jgonz...@gmail.com

unread,
Feb 21, 2013, 6:26:01 PM2/21/13
to
Bill how would I reformat the command so it will work.

Barry Margolin

unread,
Feb 21, 2013, 7:21:44 PM2/21/13
to
In article <ff5fbbbd-ccb5-49cf...@googlegroups.com>,
Actually, the problem is your quoting. You use double quotes around both
the -c parameter and the echo string, so you were undoing the quotes.

su - root -c "echo -e 'Ch9ng3m3\nCh9ng3m3\n' | password joh"

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

jgonz...@gmail.com

unread,
Feb 21, 2013, 8:52:42 PM2/21/13
to
On Thursday, February 21, 2013 11:26:20 AM UTC-8, jgonz...@gmail.com wrote:
> I create a script to create an account on a remote server that does not let you log into the server with the root account. I was able to create the account but I have not been able to put in a password for the account I created. I then just took the command su - root -c "echo -e "Ch9ng3m3\nCh9ng3m3\n" | passwd joh" out of the script and ran it on the remote server locally command line on the server and it still does not work. When I log in as root and run the command echo -e "Ch9ng3m3\nCh9ng3m3\n" | passwd joh it does work.

Barry

This works if run local on the server but from a remote server it still cmplains.
$ ssh -t 10.5.72.102 'su - root -c "echo -e 'Ch9ng3m3\nCh9ng3m3\n' | passwd john"'
Changing password for user john.
New password: Retype new password: Password change aborted.
New password: Password change aborted.
New password: Password change aborted.
passwd: Have exhausted maximum number of retries for service
Connection to 10.5.72.102 closed.
$

Barry Margolin

unread,
Feb 22, 2013, 10:04:47 AM2/22/13
to
In article <8206ee6d-9d50-48dc...@googlegroups.com>,
You need to escape the inner single quotes, otherwise they match the
outer ones.

There was a thread a couple of days ago about the best way to deal with
sending commands containing quotes via SSH, I suggest you check it out.
0 new messages