Tuesday, June 30, 2015

Initial Setting CentOS 7 - Configure VIM

Install and Configure vim that is more convenience than vi.

Install vim
[root@dlp ~]# yum -y install vim-enhanced 

Set command alias. ( Apply to all users below. If you apply to a user, Write the same settings in '~/.bashrc' )
[root@dlp ~]#
vi /etc/profile
# add at the last line

alias vi='vim'
[root@dlp ~]# source /etc/profile

Initial Setting CentOS 7 - Add Repository

Add some useful external repositories to install useful softwares
Install a plugin to add priorities to each installed repositories.


[root@dlp ~]#
yum -y install yum-plugin-priorities
# set [priority=1] to official repository

[root@dlp ~]# sed -i -e "s/\]$/\]\npriority=1/g" /etc/yum.repos.d/CentOS-Base.repo


Initial Setting CentOS 7 - Firewall and Selinux




FIREWALL

If the Firewall on the server is unnecessarry (for example, because some firewalls are allready running in your LAN ),
then stop it like follows.
If needs, refer to here to configure Firewalld.


[root@dlp ~]# 
systemctl stop firewalld 
[root@dlp ~]# 
systemctl disable firewalld 

rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'
rm '/etc/systemd/system/basic.target.wants/firewalld.service'


Basic Operation of Firewalld Centos 7

This is the Basic Operation of Firewalld.

The definition of services is set to zones on Firewalld. To enable Firewall, assosiate a zone to a NIC with related commands.

1. To use Firewalld, start it

[root@dlp ~]# 
systemctl start firewalld 

[root@dlp ~]# 

systemctl enable firewalld 

Initial Setting CentOS 7 - Add an User

Add an User "cent" as an example below.

[root@dlp ~]# 
useradd cent 

[root@dlp ~]# 
passwd cent 

Changing password for user cent.
New UNIX password:

# set password

Retype new UNIX password:

# confirm

passwd: all authentication tokens updated successfully.
[root@dlp ~]# 

exit 

Thursday, June 18, 2015

Debian/Ubuntu Linux: Restrict an SSH user session to a specific directory by setting chrooted jail

I setup a web-server. I need to grant a user ssh access but I do not trust users. How can I limit user session to a specific directory such as /home/httpd/$USERNAME? How do I set up a ssh chroort jail on a Linux operating systems?

You can interactive shell with special root directory on a Linux or Unix-like systems. You can set the pathname (such as /home/httpd/foo) of a directory to chroot to after authentication. All components of the pathname must be root owned directories that are not writable by any other user or group. After the chroot, sshd changes the working directory to the user's home directory.