LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-03-2020, 08:05 AM   #16
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,805

Rep: Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003

Quote:
Originally Posted by Honest Abe View Post
I agree with the general idea. An 'expect' script can log into multiple servers and get that information alright.
HOWEVER..

1. Expect would work serially.So at a rate of ~3 seconds per server, you are looking at a script execution time of upwards of 50 minutes.
2. The output is *not* pretty and takes extra special care if you want to redirect/log them to a file etc.
3. Needs a timeout value for ssh failure etc, else the script can run for much much longer time.
4. Since the passwords are different,you are going to have to handle the loop iteration (I use 'for') with special care too. Many organizations use a single domain userID to run automation or vulnerability analysis on their fleet of servers and can help in such scenarios.

It is one thing to pull data from a 5-10 servers or do small tests etc rather than take on a fleet of thousands. Ansible definitely gets my vote as others have mentioned.
If the OP can't even do an SSH keyswap onto these servers (post #1), chances are they won't be able to install anything else either. As TenTenths says, 600+ isn't unusual, but the OP seems to be a help-vampire, and I'm guessing (based on this and previous posts), that this is a homework question of some sort.

Either way, they have not answered or shown any effort of their own.
 
1 members found this post helpful.
Old 12-03-2020, 10:52 PM   #17
Honest Abe
Member
 
Registered: May 2018
Distribution: CentOS 7, OpenSUSE 15
Posts: 420
Blog Entries: 1

Rep: Reputation: 202Reputation: 202Reputation: 202
@TB0ne,Hence the general comment with a few hints thrown in.
OP definitely needs to show some efforts.
 
1 members found this post helpful.
Old 12-03-2020, 11:18 PM   #18
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,820

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by frankbell View Post
You may want to take a look at Cluster SSH.
I use that tool. If the OP doesn't have SSH keys set up, I can't see how it would work.
 
Old 12-03-2020, 11:52 PM   #19
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,820

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by Turbocapitalist View Post
If you do not have keys, then you might be stuck running expect and entering a lot of passwords. It is a TCL derivative.
Expect could easily read hostname and password from a file, connect to each of the hosts, issue commands to collect information, and stash it into a host-specific log file (to be parsed later and stashing information into a database perhaps). It'd take some effort to write the Expect script but doable. Expect/Tcl scripts are sort of fun to write.
 
Old 12-04-2020, 04:50 AM   #20
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,487

Rep: Reputation: 1557Reputation: 1557Reputation: 1557Reputation: 1557Reputation: 1557Reputation: 1557Reputation: 1557Reputation: 1557Reputation: 1557Reputation: 1557Reputation: 1557
Quote:
Originally Posted by rnturn View Post
Expect/Tcl scripts are sort of fun to write.
And the same script could also install a suitable public key to allow future central management with any of the tools mentioned.
 
Old 12-04-2020, 08:55 AM   #21
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,805

Rep: Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003
Quote:
Originally Posted by rnturn View Post
Expect could easily read hostname and password from a file, connect to each of the hosts, issue commands to collect information, and stash it into a host-specific log file (to be parsed later and stashing information into a database perhaps). It'd take some effort to write the Expect script but doable. Expect/Tcl scripts are sort of fun to write.
Personally, if I found out someone I hired to be an administrator for 1,000 servers keep root-level user names and passwords in a CLEAR TEXT file, and used an expect script to contact them all, I'd look for another administrator.
 
Old 12-04-2020, 11:53 AM   #22
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,382
Blog Entries: 3

Rep: Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773
Quote:
Originally Posted by TB0ne View Post
Personally, if I found out someone I hired to be an administrator for 1,000 servers keep root-level user names and passwords in a CLEAR TEXT file, ...
One place I saw tried keeping them in a M$ Word file on a Windows server. Any accounts recorded there were cracked immediately. It did not take too long to find the leak, however neither the secretary nor the Windows admin(s) were let go. The latter really needed to go.

Another place I saw actually kept an extensive plain text password file not just on a Windows server but also even in a public web directory on it available for the world to peruse. When a student pointed that out, they sued him for "hacking" and ran a series of smear articles in the local papers maligning him while lying about the infrastructure. The whole staff there really needed to be dismissed, but weren't.

I'll give the OP the benefit of the doubt, for now. Maybe this is a cleanup task. But as mentioned many times by people in this thread, SSH keys or SSH certificates are the way to go and the script's only task should be to deploy them.
 
Old 12-04-2020, 12:54 PM   #23
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,805

Rep: Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003Reputation: 8003
Quote:
Originally Posted by Turbocapitalist View Post
One place I saw tried keeping them in a M$ Word file on a Windows server. Any accounts recorded there were cracked immediately. It did not take too long to find the leak, however neither the secretary nor the Windows admin(s) were let go. The latter really needed to go.

Another place I saw actually kept an extensive plain text password file not just on a Windows server but also even in a public web directory on it available for the world to peruse. When a student pointed that out, they sued him for "hacking" and ran a series of smear articles in the local papers maligning him while lying about the infrastructure. The whole staff there really needed to be dismissed, but weren't.
I've seen similar things as well. Had this one guy years ago who paid the a__hole tax with us, because he was just plain nasty. Got a new server set up, and everything working, and gave them the speech about keeping passwords to themselves, etc. He yelled his out at the top of his lungs, and said, "You people don't know ****, and I'll do what I want!".

Cue six months later, when someone at his firm got sick of him, logged in as him and PGP encrypted every one of his files, and he wanted us to crack them. Had to explain that a 2048 bit key would take quite some time. Ranting and raving got nothing, as the person who left also encrypted the backup tapes.
Quote:
I'll give the OP the benefit of the doubt, for now. Maybe this is a cleanup task. But as mentioned many times by people in this thread, SSH keys or SSH certificates are the way to go and the script's only task should be to deploy them.
I'm betting this is a homework question, personally.
 
  


Reply



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
Is there any software/way for Linux to run one command and get it executed at 10 web servers? bmxakias Linux - Server 15 05-01-2019 04:26 AM
Better approach for running independent servers on one machine (virtualization) gameraccoon Linux - Server 5 02-28-2017 09:36 AM
two web servers behind firewall, one functioning and one in construction frankie_DJ Linux - Networking 1 08-07-2009 12:46 AM
Does Kornshell wait until one command completes before running the next command? ShaqDiesel Programming 4 09-10-2008 11:49 PM
Two X servers, one for my monitor, one for my TV using s-video out from video card? ateam Linux - Hardware 3 02-11-2005 02:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:32 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