0

In powerShell I can get some info about other system, for example with:

Get-WmiObject Win32_OperatingSystem -computer  computerName 

I know in with Linux I can do something like:

ssh computerName  uptime

but this way I have to type a password. Can it be done with no pass needed? Interesting in info like disk and memory also, maybe all run in a script. Thank you

andrej
  • 547
  • 1
  • 6
  • 21

3 Answers3

2

You may use ssh with registered rsa keys insted of password, this allow ssh commands from scripts. Follow this tutorial.

Once configured, all bash commands are accessible with:

ssh root@remoteHost "commands"

It's also a must to use vnc to query your server, allowing u to use graphic apps with very few payload (xauth and twm are enough)

j-p
  • 1,622
  • 10
  • 18
  • I was looking for something without authentication. Like windows powerShell. I change a question a bit to be more clear. Thanks – andrej Apr 20 '14 at 07:18
  • @andrej once the keys have been generated, no more password is required, but if you realy want an open door on y ou SYS, you may use telnet – j-p Apr 20 '14 at 08:49
  • do I sens from your answer that using keys is not very secure? I did `ssh-keygen ; ssh-copy-id reomteHost` and now using `ssh reomteHost "bash " < script.sh` – andrej Apr 23 '14 at 10:35
  • @andrej: it is secure, as long as all recommendations are followed. – j-p Apr 23 '14 at 11:52
1

As others have pointed out, you can ssh into a remote system without having to type a password every time by using ssh keys (google for "putty ssh keys" to find a lot of tutorials).

However, if your intent is to monitor a remote system, I think you're asking the wrong question. If you want to know the uptime, load, and other useful stats about a UNIX machine there are a couple of choices:

The former (SNMP) is a simple protocol (as the name suggests) used to monitor network devices, printers, UPS systems, and the like. I bet even your home router supports SNMP queries. A SNMP monitoring tool just sends queries over the network and parses the data it receives.

The latter (Nagios) is a framework with monitoring capabilities for various aspects of remote servers such as disk load, application status, performance, and so on. It can use SNMP and overall does quite complex tasks such as making sure a web server is still responding to a specific request, that a SMTP server is working, that a network share is not full, etc. It's a bit cumbersome to set up the first time but if you have a large infrastructure it's a must.

lorenzog
  • 3,483
  • 4
  • 29
  • 50
  • You have a very valid point there, but you are comparing apples and oranges. SNMP is a protocol, Nagios is a monitoring framework and it's very common for its plugins to pull information via SNMP (or even SSH, for that matter). Nagios does not magically gather information on its own. – Adrian Frühwirth Apr 16 '14 at 08:35
  • @AdrianFrühwirth you're right. However, they both "do the job" and are worth at least knowing about. Perhaps a SNMP query might be enough, at which point setting up a whole nagios infrastructure would be overkill. – lorenzog Apr 16 '14 at 08:38
  • Absolutely, but that's besides the point. That's like saying "you can use TCP/IP to communicate over the internet or you can use a browser" and presenting this information this way can be very misleading and confusing to someone new to the topic. I don't disagree, I just find your wording very unlucky. – Adrian Frühwirth Apr 16 '14 at 08:43
  • Both of this looks very complicated. I have a script on one centos server that for various info about uptime, disk and memory. I can run it locally and get the data. I was wondering if I could run it for remote linux system and also get the info, with no authentication needed. I change a question a bit to be more clear. Thanks – andrej Apr 20 '14 at 07:18
  • @andrej yes, in the simplest case you need to create a ssh key with the command `ssh-keygen` and by following the tutorials posted in the answer of user "j-p". It's a one-off; once the keys are in place, you can run ssh without the need to enter passwords. – lorenzog Apr 20 '14 at 08:28
0

You could use Hping.

It's a command-line oriented TCP/IP packet assembler/analyzer (the interface is inspired to ping).

The --tcp-timestamp switch will "guess" the uptime (details in Phrack Volume 0x0b, Issue 0x3f, Phile #0x01 of 0x14).

hping3 --tcp-timestamp -S ip.remote.host -p 80

TCP timestamp is not the only method of getting knowledge about uptime of remote server. You can find some more ideas/tools in Why uptime can be dangerous.

manlio
  • 18,345
  • 14
  • 76
  • 126
  • Actually I am interesting also in other info, like disk and memory. I change a question a bit to be more clear. Thanks – andrej Apr 20 '14 at 07:19