Sponsored Content
Top Forums Shell Programming and Scripting Encyrpt does not work in bash script Post 303002850 by yash_message on Sunday 3rd of September 2017 12:21:16 PM
Old 09-03-2017
Jim, Thanks for your reply.

I have changed in the script, what you suggested. but in shadow file does not put password correctly. it left after dollar($) sign.
It works fine in command prompt.

Please find my script and running output.

Code:
[root@server-rhel6 ~]# cat adduser.sh
#!/bin/bash
for i in `cat servername1`;
do
ssh -q -t root@$i sudo /usr/sbin/useradd -u 1001 -s /bin/bash -m -d /home/testuser -c 'URid_testuser-p "\$6\$h8GQyPz4\$I1C.whHxlC65VYVfnEfSunDf8W.zTl3OtU2p6fULLG0S7JGMnfrvCytj3VGBsZ3gK./fUDTL.Vxxxd22u48St." testuser
echo testuser created on server $i
done

Running script with -x option-----

Code:
[root@server-rhel6 ~]# sh -x adduser.sh
++ cat servername1
+ for i in '`cat servername1`'
+ ssh -q -t root@node1-rhel6 sudo /usr/sbin/useradd -u 1001-p '$6$h8GQyPz4$I1C.whHxlC65VYVfnEfSunDf8W.zTl3OtU2p6fULLG0S7JGMnfrvCytj3VGBsZ3gK./fUDTL.Vxxxd22u48St.' testuser
+ echo testuser created on server node1-rhel6
testuser created on server node1-rhel6
+ for i in '`cat servername1`'
+ ssh -q -t root@node2-rhel6 sudo /usr/sbin/useradd -u 1001 -s /bin/bash -m -d /home/adubey01 -c URid_testuser -p '$6$h8GQyPz4$I1C.whHxlC65VYVfnEfSunDf8W.zTl3OtU2p6fULLG0S7JGMnfrvCytj3VGBsZ3gK./fUDTL.Vxxxd22u48St.' testuser
+ echo testuser created on server node2-rhel6
testuser created on server node2-rhel6
[root@server-rhel6 ~]#

Shadow file output-----

Code:
testuser:.whHxlC65VYVfnEfSunDf8W.zTl3OtU2p6fULLG0S7JGMnfrvCytj3VGBsZ3gK./fUDTL.Vxxxd22u48St.:17410:0:99999:7:::

Please suggest.


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 09-03-2017 at 01:31 PM.. Reason: Added CODE tags.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script doesn't work, but commands inside work

Howdie everyone... I have a shell script RemoveFiles.sh Inside this file, it only has two commands as below: rm -f ../../reportToday/temp/* rm -f ../../report/* My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Discussion started by: cheongww
2 Replies

2. Shell Programming and Scripting

Open and work on a .doc file with bash script

Hello there....unix users :) I hope you can help me with this: I need open a doc file or xls files and work this files whit a bash script. For example: Open a doc file and copy information from a txt file in this doc file or xls file. Is it possible? Sorry for my english...I'm chilean... (3 Replies)
Discussion started by: bobbasystem
3 Replies

3. Shell Programming and Scripting

cant get a counter to work in bash scipt, this is calling expect script

I have looked high and low, tryed lots of diffrent things but cant get a simple counter to work right. what i need is to increase a count ever time it finishes the test, pass or fail. example TEST PASS 1, NEXT TEST PASS 2, I curently have set foo o while {$foo <=5} { incr foo puts... (1 Reply)
Discussion started by: melvin
1 Replies

4. Shell Programming and Scripting

pipe to grep doesn't work in bash script

Hi, I'm trying to write a script that checks gvfs to see if a mount exists so I can run it from network-manager's status hooks. I thought I'd pipe the output of gvfs-mount -l to grep for the particular mounts I care about. When I do this in a bash script: cmnd="gvfs-mount -l | grep -i... (4 Replies)
Discussion started by: kcstrom
4 Replies

5. Shell Programming and Scripting

My script work on Linux but not work in sunos.

My script work on Linux but not work in sun os. my script. logFiles="sentLog1.log sentLog2.log" intial_time="0 0" logLocation="/usr/local/tomcat/logs/" sleepTime=600 failMessage=":: $(tput bold)Log not update$(tput rmso) = " successMessage="OK" arr=($logFiles)... (7 Replies)
Discussion started by: ooilinlove
7 Replies

6. Shell Programming and Scripting

Nested double quotes won't work in my bash script?

In a bash script I have: LSCMD="find /project/media/ -mindepth 2 -maxdepth 2 -name \"files*pkg\"" ALL_PACKAGES=$( $LSCMD | sort 2>/dev/null) But I get nothing returned. It's just all blank. If I run the find command in a terminal, I get dozens of hits. I figure it's the way how I'm... (3 Replies)
Discussion started by: superbbrr
3 Replies

7. Shell Programming and Scripting

Rsync in bash script doesn't work even after placing pub key in target server

Hello Friends, My bash script is like this #!/bin/bash # request Bourne shell as shell for job #$ -S /bin/bash # assume current working directory as paths #$ -cwd #$ -N rsync-copy # # print date and time date rsync -rltD --progress "ssh -i /home/myname/.ssh/id_rsa"... (4 Replies)
Discussion started by: jacobs.smith
4 Replies

8. Shell Programming and Scripting

Bash script: "mkdir -p" doesn't work with var(cat x)

Hello, :) I've an issue with the creation of a directory, All work without it :mad: So, below, my scripts with the debug output : #!/bin/bash # PATHS HOME_BACKUP="/home/backup" HOME_SCRIPT="/home/scripts/test/backup_server" TARGET="/var/www" # DATE DATE_Ymd=$(date +%Y-%m-%d) #... (1 Reply)
Discussion started by: Arnaudh78
1 Replies

9. AIX

Bash does not work on AIX 7.2

We have a new LPAR with AIX 7.2. We want to work with bash, so installed bash from Perzl (bash_64-4.4.5.aix5.1.ppc.rpm). But after install bash does not work. If I call "bash", nothing happens. The xterm, where I started bash, is totally dead. I tried the bash from aixtools.net, too. Same... (4 Replies)
Discussion started by: BuSchu
4 Replies

10. UNIX for Beginners Questions & Answers

Bash script does not work as expected

Repeat this text in a file named notes.txt and run the script Before bash is a good language a blank line appears Also, the following notes are displayed incorrectly What is bad? ================================== Title : Note 1 ================================== Category: Computer Date... (3 Replies)
Discussion started by: cesar60
3 Replies
bup-on(1)						      General Commands Manual							 bup-on(1)

NAME
bup-on - run a bup server locally and client remotely SYNOPSIS
bup on <hostname> index ... bup on <hostname> save ... bup on <hostname> split ... DESCRIPTION
bup on runs the given bup command on the given host using ssh. It runs a bup server on the local machine, so that commands like bup save on the remote machine can back up to the local machine. (You don't need to provide a --remote option to bup save in order for this to work.) See bup-index(1), bup-save(1), and so on for details of how each subcommand works. This 'reverse mode' operation is useful when the machine being backed up isn't supposed to be able to ssh into the backup server. For example, your backup server can be hidden behind a one-way firewall on a private or dynamic IP address; using an ssh key, it can be autho- rized to ssh into each of your important machines. After connecting to each destination machine, it initiates a backup, receiving the resulting data and storing in its local repository. For example, if you run several virtual private Linux machines on a remote hosting provider, you could back them up to a local (much less expensive) computer in your basement. EXAMPLES
# First index the files on the remote server $ bup on myserver index -vux /etc bup server: reading from stdin. Indexing: 2465, done. bup: merging indexes (186668/186668), done. bup server: done # Now save the files from the remote server to the # local $BUP_DIR $ bup on myserver save -n myserver-backup /etc bup server: reading from stdin. bup server: command: 'list-indexes' PackIdxList: using 7 indexes. Saving: 100.00% (241/241k, 648/648 files), done. bup server: received 55 objects. Indexing objects: 100% (55/55), done. bup server: command: 'quit' bup server: done # Now we can look at the resulting repo on the local # machine $ bup ftp 'cat /myserver-backup/latest/etc/passwd' root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh sync:x:4:65534:sync:/bin:/bin/sync ... SEE ALSO
bup-index(1), bup-save(1), bup-split(1) BUP
Part of the bup(1) suite. AUTHORS
Avery Pennarun <apenwarr@gmail.com>. Bup unknown- bup-on(1)
All times are GMT -4. The time now is 04:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy