Several things to note:
- Don't use
root
if you don't need to. Foruptime
andcat /proc/meminfo
you certainly don't needroot
. Use another user. Note the difference between these two:
ssh user@hostname uptime && cat /proc/meminfo ssh user@hostname 'uptime && cat /proc/meminfo'
The first one will execute
cat /proc/meminfo
on your local machine, the second will execute it on the remote. I think you want to use the second version. (You want the CPU info of the remote machine, not your local machine, do you?)
You can use connection multiplexing to hit two birds with one stone: reduce the overhead of establishing new connections and avoid polluting the server log. To do this, add a configuration like this in your ~/.ssh/config
file:
Host somename
User the_username
Hostname the_hostname
ControlMaster auto
ControlPath ~/.ssh/master-somename
You can choose any somename
, it's like an alias. With this setting, you can connect to the server simply as:
ssh somename
While this remote session is still alive (until you logout), you can open new connections from another terminal, and they will reuse the existing connection, bypassing authentication and effectively eliminating the overhead of new connections.
This is actually a common trick when working with slow remote servers where establishing new connections is a noticeable overhead. In fact I use this setting to apply it to all remote servers I work with:
Host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p
I usually recommend this trick for everyone.