Search Results

Search: Posts Made By: fugeulu
32,872
Posted By Chubler_XL
Yes, most new shell versions support either...
Yes, most new shell versions support either $(command) or `command` command substitution styles. I feel the newer $() style is easier to read and looks much better when nested.
32,872
Posted By DGPickett
Yes, the $() is nicer, suggest the actual...
Yes, the $() is nicer, suggest the actual subshell, nests, and supports vi % end finder and similar GUI IDE tools. Just make your 'case' test entries not "xxx*)" as in old examples, but the perfectly...
32,872
Posted By Chubler_XL
Looks like three backslashes if backticks are...
Looks like three backslashes if backticks are used then:

RUID=`ssh $i awk -F: '\\\$3=="'$UNIQUE'"' /etc/passwd`

or

RUID=$(ssh $i awk -F: '\$3=="'$UNIQUE'"' /etc/passwd)
32,872
Posted By DGPickett
Is it usual to manage users by number manually...
Is it usual to manage users by number manually across mny machines? People usually care more about the login user name id.
32,872
Posted By MadeInGermany
Your problem is that the right side of the pipe...
Your problem is that the right side of the pipe is executed on the calling host.
You need to force it to the remote host, by quoting:
ssh $i echo "$PASSWORD" "|" passwd --stdin "$UNAME"or simpler...
32,872
Posted By DGPickett
Passwords should be random and expired already.
Passwords should be random and expired already.
32,872
Posted By Chubler_XL
You should take a look at this thread: ...
You should take a look at this thread:

https://www.unix.com/shell-programming-scripting/215631-create-users-remotely.html

In which I propose using the -p parameter of useradd to create the user...
32,872
Posted By DGPickett
You can put a whole script on the command line,...
You can put a whole script on the command line, or just send it into ssh bash. I prefer "echo '...'|ssh ...." but "<<!" is pretty popular, too, just be careful to escape meta like $ from local...
32,872
Posted By DGPickett
I would do one ssh per host and ship the...
I would do one ssh per host and ship the scripting to the remote host, for speed and simplicity.

For getting hosts from your config file, just:while read i
do
...
done < file

For good...
32,872
Posted By DGPickett
Yes, at least with echo ' ... ' | ssh .... it is...
Yes, at least with echo ' ... ' | ssh .... it is easy to predict what goes down the pipe. It is not that hard to type '"'"' when you need a '.
32,872
Posted By MadeInGermany
An attempt for an optimized script: #!/bin/bash...
An attempt for an optimized script:
#!/bin/bash

HOSTS="/tmp/test/serverlist"
DDID="IDENTIFY"
HOMEPATH="/home/$UNAME"

# read from $DDID
while read UNIQUE UNAME PASSWORD ROLE
do
# read...
32,872
Posted By Chubler_XL
-m will only create the home directory if...
-m will only create the home directory if CREATE_HOME in /etc/login.defs is set to yes.


Don't think this test is correct, UID may appear in other places in password file (eg phone extension,...
32,872
Posted By DGPickett
The userid was $1 last I looked! OK, maybe user...
The userid was $1 last I looked! OK, maybe user name, but isn't that what admins should be keying on? If you want the uid to match on all hosts, it's yp/nis time.
Showing results 1 to 13 of 13

 
All times are GMT -4. The time now is 04:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy