monitoring process activity
load average is : 1 minute, 5 minutes, 15 minutes moving exponential average
|
|
figure out how many logical CPUs you have, and divide the load average by that number, yield is percent of load over period of time. 100% is fully loaded, more is overloaded.
lscpu
: see how many CPUs you have
I have 4
controlling services and daemons
units are initialized by systemd
- service
- socket
- target
- device
|
|
masking and unmasking
using ssh
stores user fingerprints on user’s server in known_hosts, which is a record of servers visited
man in the middle, fake server configures itself with the ip address of servera, but fake server will have a different fingerprint, which will fail to match against the known-hosts file and warn about a man-in-the-middle
what may have happened instead is that servera was restored, and they forgot to back up the fingerprint information
you can add the correct known key to fix this error
can put settings in ~/.ssh/config to enforce strict host key checking and set the default auth method to ssh keys
configuring ssh key-based authentication
asymmetric cryptopgraphic mechanism
private key
- for descrypting data
- may be secured with passphrase public key
- for encrypting data
- publicly accessible
- saved on target ssh server in home directory
connecting:
- remote machine will generate a challenge, which is encrypted with your public key
- if you can decrypt the data with your private key, you are allowed to make a connection
|
|
customizing openssh service configuration
locking down ssh daemon so it’s more secure; prevent the root user from logging in
|
|
change PermitRootLogin yes
to PermitRootLogin no
systemctl reload ssh
: reload the process
now logins will show permission denied
ultimately we want to prevent password auth by distributing a private key for users to auth against a target server, or having them provide their public keys
can also do:
ssh -o PubkeyAuthentication=no -o PasswordAuthentication=yes user@server
bonus
log bash history to a file
add to ~/.bashrc
|
|
analyzing and storing logs
journal collects messages from:
- output of booting
- daemons start/run
- syslog chatter
journal powered by systemd-journald, accessed by journalctl
|
|
rsyslog takes syslog messages to /var/log
rsyslog protocol
- facility
- priority
authpriv.notice
: can redirect messages /var/log/foo
rsyslog’s main config file is /etc/rsyslog.conf
/etc/rsyslog.d/
: can be used as a drop-in directory for configuration files
use logger -p local6.warn
to send a message to local6 facility at warning priority
logrotate
: prevents log files from growing too large
customize the policy at /etc/logrotate.conf
and /etc/logrotate.d/
using the journal
|
|
syslog priorities (least to most)
- debug
- info
- notice
- warn
- err
- crit
- alert
- emerg
|
|