Multiple entry in .ssh/config file

Here is a link to one post on ssh config file.

However, if you want entries for lot of servers with their IPs or names, then it could be cumbersome to add all the entries in the .ssh/config file. So, here is a shortcut notation:

Host 1 2 3 4 5 6
Hostname 192.168.1.%h
    User 
    
    Ciphers arcfour

where '%h' denotes the IP that you use in the ssh command.

The following escape character substitutions will be performed:
             ‘%d’ (local user's home directory), ‘%h’ (remote host name), ‘%l’ (local host name),
              ‘%n’ (host name as provided on the command line), ‘%p’ (remote port),
              ‘%r’ (remote user name) or ‘%u’ (local user name).

cgroups – use to control your cpu and memory

cgroups is a kernel feature and with userspace utilities, we can use the feature to control the cpu and memory for per process. So, lets first install the required tools.

sudo yum install libcgroup-tools

Now, we need to enable the service.

sudo systemctl enable cgconfig.service
sudo systemctl enable cgred.service

cgconfig.service is to enable configuration for cgroups and
cgred.service is to enable configuration for cgroups for processes depending on the name.

Now, we will need to configure the cgroups and configure the groups for the processes. So, lets open up the configuration files and do some configuration:

Here we will use firefox as the group name and use firefox as an example to restrict the memory to 700Mb and cpu to 10%. Since we do not have any other group configured right now, so max being 1024 – 100 shares would be around 10%.

First, open up the /etc/cgconfig.conf file and add the following. You would need to replace below with your username.

group firefox {
perm {
task {
uid = ;
gid = ;
}
admin {
uid = ;
gid = ;
}
}

cpu{
cpu.shares=”102″;
}
cpuset{
cpuset.cpus=0;
cpuset.mems=0;
}
memory {
memory.limit_in_bytes=”700M”;
memory.max_usage_in_bytes=”0″;
}
}

Now, we edit the /etc/cgrules.conf file and add the following:

:sandbox cpu,memory firefox
::firefox cpu,memory firefox

All done. Now, time to test.

First restart the services.

sudo systemctl restart cgconfig.service
sudo systemctl restart cgred.service

Check, if the cgroup is created. Go to directory:

/sys/fs/cgroup/memory or /sys/fs/cgroup/cpu

and check directory firefox exists.

Note: You can check the cgroup mount directory with mount command to see where your cgroups are mounted.

Now, start firefox, check the pid and check the file /proc//cgroup and you should see something like this:

11:hugetlb:/
10:perf_event:/
9:blkio:/
8:net_cls:/
7:freezer:/
6:devices:/
5:memory:/firefox
4:cpuacct,cpu:/firefox
3:cpuset:/
2:name=systemd:/user.slice/user-1000.slice/session-1.scope

and this is it.

Enhanced by Zemanta

ssmtp configuration and installation – raspberry pi.

English: Extract from Raspberry Pi board at Tr...
English: Extract from Raspberry Pi board at TransferSummit 2011 (Photo credit: Wikipedia)

To get your email working on your raspberry pi, First thing that you should probably do is to set up outgoing emails from your RPi. The easiest way to do so is with ssmtp.

Install ssmtp:

sudo apt-get install ssmtp

Next configure the ssmtp client to send emails using your ISP, open up the file /etc/ssmtp/ssmtp.conf file and make the changes as suggested below:

#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster

# The place where the mail goes. The actual machine name is required no 
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=

# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname
hostname=

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# We would want this to be on so that we can set the from line
# from scripts as well.
# NO - Use the system generated From: address
FromLineOverride=YES
AuthUser=
AuthPass=

Now, check that you can send emails using the command :

echo "Test message"|ssmtp <your email address>

That should keep you going 🙂

Enhanced by Zemanta