OK. actually this is a very simple configuration. anyway I'll guide you through the configurations.
Open your switch command line and follow the configurations given below.
Switch>enable
Switch#configure terminal
Go in to the interface which you want to apply security.
Switch(config)#interface FastEthernet 0/1
Configure the port as an access port. It tells that this port is going to connect to a End device.
Switch(config-if)#switchport mode accesss
Then we need to enable port security
Switch(config-if)#switchport port-security
Then you need to configure the maximum number of devices to be allowed. your requirement is 2 devices.
Switch(config-if)#switchport port-security maximum 2
after that you can provide the mac address of each device
Switch(config-if)#switchport port-security mac-address 5aa9.0320.02ab
Switch(config-if)#switchport port-security mac-address 4ab3.0020.02ba
ultimately you want to shut down the interface if there is any security violation. lets do it...
Switch(config-if)#switchport port-security violation shutdown
Done..
