Showing posts with label Security. Show all posts
Showing posts with label Security. Show all posts

Monday, April 20, 2015

How to check SSL Certificate information from a Linux server?

-bash-3.2# echo | openssl s_client -connect starcat:443 2>/dev/null | openssl x509 -noout -issuer -subject -dates 
issuer= /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 High Assurance Server CA
subject= /C=US/ST=California/L=Santa Clara/O=ABC Company, Inc./CN=*.abc.com
notBefore=Dec  9 00:00:00 2013 GMT
notAfter=Feb 23 12:00:00 2017 GMT


-bash-3.2# echo | openssl s_client -connect unix:443 2>/dev/null | openssl x509 -noout -issuer -subject -dates 
issuer= /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 High Assurance Server CA
subject= /C=US/ST=California/L=Santa Clara/O=ABC Company, Inc./CN=*.abc.com
notBefore=Dec  9 00:00:00 2013 GMT
notAfter=Feb 23 12:00:00 2017 GMT

Wednesday, February 13, 2013

How to encrypt and decrypt any file in Solaris?

How to encrypt/decrypt any file in Solaris:
  1. Identify the file need to be encrypted
  2. Use “crypt < filename > encrypted_file_name”
    • This process will ask for a key – this will become password to open that file.
  3. Note that while encrypting the file, the original file will be deleted.
  4. Next is how to read that encrypted file:
    • Use “crypt < encrypted_file_name”
    • This process will ask for same password which was given initially while encrypting the file.
Input data file:
unixgeek(staff)@server1[66]> cat important
THis is an important file!

To encrypt:
unixgeek(staff)@server1[67]> crypt < important > out
Enter key: UNIXTEAM   Note:: “UNIXTEAM” will become password to decrypt this file.

To Decrypt:
unixgeek(staff)@server1[68]> crypt < out
Enter key: UNIXTEAM   Note:: Same password to decrypt this file as given during encrypting the file.
THis is an important file!
Enjoy!!! :)

Thursday, April 30, 2009

Netgroup (using NIS) implementation - Solaris

I wanted to limit only a certain number of users from NIS to login to some servers using NIS. The simplest way to do this is to use netgroups. It is NIS map created separately to restrict users to login certain machines, to export any file system to certain servers only and provide many other features.

To restrict users to any server, here are the simplest steps:

Step 1:
On NIS server, edit "netgroup" map and add:

#tail -1 /etc/yp/netgroup
splgroup username1 username2 username3

Step 2:
On NIS server, Re-Make this map by doing following:
# cd /var/yp
# ./make netgroup

Step 3:
On NIS client (i.e. where I need to restrict users)
Edit /etc/passwd file and add the following line:

+@splgroup:x:::::

Edit /etc/shadow file and add following line:
+@splgroup::::::::

Edit /etc/nsswitch.conf file and in passwd entry, change as follows:
passwd: compat

Restart NIS client. For Solaris 10, it can be done by:
# svcadm refresh /network/nis/client



With "splgroup" netgroup in place, only "username1 - 3" will be allowed to login to the NIS client.

How to allow ONLY selected users to ssh a server?

Recently, I had a requirement where I have to allow only 3-4 users to be able to ssh a server. This server was for specific purpose and we did not want everyone to login there. For this, I disabled telnet/rlogin/ftp/rsh and any other possible way to connect to the server except ssh.

For further filtering in ssh to allow only selected users, I modified /etc/ssh/sshd_config file to add following line:

AllowUsers unixgeek paul john


One more thing, while doing this, make sure to restart ssh by doing following:

For Solaris 10 OS:
# svcadm refresh svc:/network/ssh

For Redhat Linux
# service sshd restart


With this in place, only unixgeek, paul and john will be able to ssh to this server.

Voila! Mission accomplished! :-)

Sunday, February 22, 2009

How to disable all logins?

Some servers are meant to only serve few specific ports and in this case, server administrator should disable the normal login process. In my case, I wanted to have alerts when someone tries to even login to this server and I configured /etc/hosts.deny file to send alerts to me. This is good for at least Solaris OS.


# cat /etc/hosts.deny
ALL: ALL: /usr/ucb/finger -l @%h 2>&1 | /bin/mailx -s "Someone is knocking at `hostname`" unixgeek@somecompany.com