LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware > Slackware - Installation
User Name
Password
Slackware - Installation This forum is for the discussion of installation issues with Slackware.

Notices


Reply
  Search this Thread
Old 01-20-2016, 12:21 AM   #1
mail2ganesh.cse
Member
 
Registered: Apr 2012
Posts: 65

Rep: Reputation: Disabled
bash script for reset the user and root password


Hi friends,

I need to create a bash script for reset a root password and user password for multiple servers and it doesnt have direct root access in cent os. so can u please help on this.

the process are like this for multiple servers

ssh sas@serverip
su -
passwd
new password
new password
password successfully updated
passwd sas
new password
new password
password successfully updated
exit.
 
Old 01-20-2016, 07:39 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,801

Rep: Reputation: 8198Reputation: 8198Reputation: 8198Reputation: 8198Reputation: 8198Reputation: 8198Reputation: 8198Reputation: 8198Reputation: 8198Reputation: 8198Reputation: 8198
Quote:
Originally Posted by mail2ganesh.cse View Post
Hi friends,
I need to create a bash script for reset a root password and user password for multiple servers and it doesnt have direct root access in cent os. so can u please help on this. the process are like this for multiple servers

ssh sas@serverip
su -
passwd
new password
new password
password successfully updated
passwd sas
new password
new password
password successfully updated
exit.
As you've been asked MANY times previously, SPELL OUT YOUR WORDS, and STOP USING TEXT SPEAK....read the LQ Rules. And also, read the Question Guidelines Link in my posting signature. We will HELP you, but you, PERSONALLY, need to show some effort of your own. Post the script that you have written, what you've tried, and what message(s)/error(s) you're getting, and we will be happy to help.

Otherwise, we are NOT going to write a script for you. There are many thousands of bash-scripting you can find with a Google search...and since you've been here for four years now, you should know we're not going to write you a script.
 
Old 01-20-2016, 08:29 AM   #3
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8120Reputation: 8120Reputation: 8120Reputation: 8120Reputation: 8120Reputation: 8120Reputation: 8120Reputation: 8120Reputation: 8120Reputation: 8120Reputation: 8120
Also, you indicate that this is a script you want to run on existing CentOS servers, so why are you posting in "Slackware - Installation" forum? No-one is going to take you seriously.
 
1 members found this post helpful.
Old 01-21-2016, 05:32 AM   #4
mail2ganesh.cse
Member
 
Registered: Apr 2012
Posts: 65

Original Poster
Rep: Reputation: Disabled
Hi,

i have written below, and its direct root to change it, but i need to know logging as user(sas) and then need to go root user and change the both user & root password.

ganesh-1684@landing~>cat passwordreset.sh
for server in `cat servers.txt`; do
ssh $server -l sas 'passwd <<EOF
old_pass
new_pass
new_pass
EOF';
done
ganesh-1684@landing~>
 
Old 01-21-2016, 11:20 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,801

Rep: Reputation: 8198Reputation: 8198Reputation: 8198Reputation: 8198Reputation: 8198Reputation: 8198Reputation: 8198Reputation: 8198Reputation: 8198Reputation: 8198Reputation: 8198
Quote:
Originally Posted by mail2ganesh.cse View Post
Hi,

i have written below, and its direct root to change it, but i need to know logging as user(sas) and then need to go root user and change the both user & root password.

ganesh-1684@landing~>cat passwordreset.sh
for server in `cat servers.txt`; do
ssh $server -l sas 'passwd <<EOF
old_pass
new_pass
new_pass
EOF';
done
ganesh-1684@landing~>
Ok, so either use "su - root" or "sudo <command>". And this script is horribly insecure...changing the root password should NEVER be trivial. Anyone who can even FIND this script on your server, can then change the root passwords on ALL your servers, and do whatever they please. Or (worse), just SEE the password (since you're keeping it in clear text), log in as root, and lock EVERYONE out.
 
  


Reply

Tags
bashs script, centos7, password


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
unable to access machine with root user. password reset not helpfully. NagabhushanaDevineni Linux - Server 2 10-22-2015 07:29 PM
reset vnc root user password anis123 Linux - Server 1 04-21-2015 11:55 AM
[SOLVED] How to recover/reset log on password of user other than root mq15 Linux - Newbie 3 04-22-2012 04:16 AM
Bash script to reset admin password with chntpw hal8000b Programming 2 12-15-2008 02:47 AM
Reset user password via script fluffyvoidbunny SUSE / openSUSE 8 03-10-2006 02:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware > Slackware - Installation

All times are GMT -5. The time now is 10:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration