View previous topic :: View next topic |
Author |
Message |
audiodef Watchman


Joined: 06 Jul 2005 Posts: 6656 Location: The soundosphere
|
Posted: Mon Jan 25, 2016 2:05 am Post subject: How do I securely perform remote server monitoring? |
|
|
I set up a server so that gkrellmd can only be accessed through ssh. I want to turn the necessary lines into a script, like so:
Code: |
#!/bin/bash
ssh -N -f -L 19150:127.0.0.1:19150 (user)@(ip_address)
gkrellm -s 127.0.0.1 -P 19150 &
|
The problem is ssh can't get a password from me this way. How do I write this with the password included? _________________ decibel Linux: https://decibellinux.org
Github: https://github.com/Gentoo-Music-and-Audio-Technology
Facebook: https://www.facebook.com/decibellinux
Discord: https://discord.gg/73XV24dNPN
Last edited by audiodef on Mon Jan 25, 2016 4:34 pm; edited 1 time in total |
|
Back to top |
|
 |
khayyam Watchman


Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Mon Jan 25, 2016 2:27 am Post subject: |
|
|
audiodef ...
if you want passwordless logins then use a (passwordless) key.
best ... khay |
|
Back to top |
|
 |
audiodef Watchman


Joined: 06 Jul 2005 Posts: 6656 Location: The soundosphere
|
|
Back to top |
|
 |
Syl20 l33t


Joined: 04 Aug 2005 Posts: 621 Location: France
|
Posted: Mon Jan 25, 2016 5:14 pm Post subject: |
|
|
What do you want to monitor ? Do you want to monitor your system through internet ?
On a LAN, and if you have a little time to setup a server, Nagios (with NRPE), for example, is certainly more appropriate than a set of home-made patches around a localhost-focused tool. |
|
Back to top |
|
 |
khayyam Watchman


Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Mon Jan 25, 2016 7:12 pm Post subject: |
|
|
audiodef wrote: | I don't want to compromise whatever security measures I've set up on my server |
audiodef ... in what way would the use of a key compromise security?
audiodef wrote: | [...] so I guess a better question is: What is the best way to perform remote server monitoring in a secure way? |
As CneGroumF points out that depends on your needs, nagios/icinga offers many plugins (ie, fail2ban, mysql, openvpn) and a web interface, and is the oft used solution for such things.
best ... khay |
|
Back to top |
|
 |
audiodef Watchman


Joined: 06 Jul 2005 Posts: 6656 Location: The soundosphere
|
|
Back to top |
|
 |
audiodef Watchman


Joined: 06 Jul 2005 Posts: 6656 Location: The soundosphere
|
|
Back to top |
|
 |
khayyam Watchman


Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Mon Jan 25, 2016 7:27 pm Post subject: |
|
|
audiodef wrote: | I want to monitor general server stuff for now: uptime, cpu load, mem, processes - the stuff you get through gkrellm. It's not on a LAN - it's a remote hosted server. |
audiodef ... personally I wouldn't want to be bothered with such stuff, only be alerted as and when something occurs which needs my attention. However, for your initial problem all you need do is setup a key and have the key added to ssh-agent on login (via sys-auth/pam_ssh or net-misc/keychain) ... your script should then function without the need of a passphrase (because a key exchange would be used for authentication).
best ... khay |
|
Back to top |
|
 |
krinn Watchman


Joined: 02 May 2003 Posts: 7471
|
Posted: Mon Jan 25, 2016 9:00 pm Post subject: |
|
|
i'm with khayyam there, first key isn't less secure than a password, i wouldn't claim it's even more secure but that's still what i think.
if you really don't want use password or keys, then use a solution that use none: you could build a file with infos you want from the server and upload it to your computer thru ftp (using an annon access with a fake email as password), this way, you'll get what you want without sharing any key or real password.
you might just send the file by email if you prefer. |
|
Back to top |
|
 |
audiodef Watchman


Joined: 06 Jul 2005 Posts: 6656 Location: The soundosphere
|
|
Back to top |
|
 |
khayyam Watchman


Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Tue Jan 26, 2016 1:59 am Post subject: |
|
|
audiodef wrote: | Found a simple way to do what I wanted: emerge tilda, set it to fill up 100% of my screen in the background, no taskbar or pager, just ssh in normally and leave htop running. |
audiodef ... or you could pass the command to run:
Code: | $ ssh user@host htop |
best ... khay |
|
Back to top |
|
 |
dalu Guru


Joined: 20 Jan 2003 Posts: 533
|
Posted: Tue Jan 26, 2016 2:53 am Post subject: |
|
|
what would I want to monitor indeed..
when I wanted to write my own
net
/sys/class/net/<ifname>/statistics/
or
/proc/net/dev
cpu
/proc/stat
disk
/proc/diskstats
memory
/proc/meminfo
what else could be monitored? |
|
Back to top |
|
 |
audiodef Watchman


Joined: 06 Jul 2005 Posts: 6656 Location: The soundosphere
|
|
Back to top |
|
 |
audiodef Watchman


Joined: 06 Jul 2005 Posts: 6656 Location: The soundosphere
|
Posted: Tue Jan 26, 2016 3:25 pm Post subject: |
|
|
dalu wrote: | what would I want to monitor indeed..
when I wanted to write my own
net
/sys/class/net/<ifname>/statistics/
or
/proc/net/dev
cpu
/proc/stat
disk
/proc/diskstats
memory
/proc/meminfo
what else could be monitored? |
I learned a little more since my OP. You can monitor all kinds of things in all kinds of detail. I found a couple of other useful top utils: apachetop and mytop. There are top programs for various types of network monitoring and packet sniffing, etc. atop is another useful general info top program that shows more detail in an organized way than top. _________________ decibel Linux: https://decibellinux.org
Github: https://github.com/Gentoo-Music-and-Audio-Technology
Facebook: https://www.facebook.com/decibellinux
Discord: https://discord.gg/73XV24dNPN |
|
Back to top |
|
 |
khayyam Watchman


Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Tue Jan 26, 2016 8:12 pm Post subject: |
|
|
audiodef wrote: | Code: | $ ssh user@host htop |
|
I actually tried that but got an error about unknown terminal.[/quote]
audiodef ... hmmm, so what is $TERM reporting?
best ... khay |
|
Back to top |
|
 |
audiodef Watchman


Joined: 06 Jul 2005 Posts: 6656 Location: The soundosphere
|
|
Back to top |
|
 |
enZom n00b


Joined: 13 Nov 2015 Posts: 30 Location: In a sandbox
|
Posted: Wed Jan 27, 2016 2:25 am Post subject: |
|
|
You could look into using a 2048 bit or higher key.
@monitoring
I often run multiple windows of lnav looking at different log files.
For split windows Tmux or if you're @ a desktop terminator works.
The watch command can be helpful too.
Code: | watch grep \"cpu MHz\" /proc/cpuinfo |
Code: | watch cat /proc/net/ip_conntrack
#Or if you have the rest of the conntrack goodies installed.
conntrack -E |
Code: | watch netstat -atnu |
Also a fan of jnettop
|
|
Back to top |
|
 |
ShaneCar n00b

Joined: 27 Oct 2015 Posts: 4 Location: San Francisco
|
Posted: Thu Jan 28, 2016 3:32 am Post subject: |
|
|
Nagios (NRPE) would save you some time setting up the setting up the server. If uptime, cpu load, mem, and processes is what you care about, then that seems like the best option. BigPanda, while not open source, is also an interesting tool. It plugs right into Nagios- https://bigpanda.io/integrations/nagios-the-alternative-to-a-flood-of-alerts- and will sift through all the noise for you, so all you're looking at is high level data thats meaningful. Either way, I think NRPE will save you time and headache. _________________ Everything Cloud, infrastructure, monitoring, scaling. |
|
Back to top |
|
 |
audiodef Watchman


Joined: 06 Jul 2005 Posts: 6656 Location: The soundosphere
|
|
Back to top |
|
 |
Ant P. Watchman

Joined: 18 Apr 2009 Posts: 6920
|
Posted: Mon Feb 01, 2016 7:24 pm Post subject: |
|
|
khayyam wrote: | audiodef wrote: | Code: | $ ssh user@host htop |
|
I actually tried that but got an error about unknown terminal. |
You need to write it as ssh -t htop, otherwise the default when a command is passed to ssh is to run it with only dumb pipes for stdin/out. |
|
Back to top |
|
 |
audiodef Watchman


Joined: 06 Jul 2005 Posts: 6656 Location: The soundosphere
|
|
Back to top |
|
 |
|