Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Tuesday, March 22, 2016

How to Restrict ssh Access

How to Restrict SSH Access for User1

  1. Modify /etc/security/access.conf and add the following line at bottom of file
    1. - :User1:ALL EXCEPT server1.example.com server1 server2.example.com LOCAL
  2. Verify these configuration are set in /etc/ssh/sshd_config
    1. UsePAM yes
    2. PasswordAuthentication yes
    3. ChallengeResponseAuthentication no
  3. Verify or modify /etc/ssh/sshd_config and remove tomcat from DenyUsers if listed
    1. DenyUsers UserX UserY UserZ
    2. NOTE: (Only need to modify sshd in pam.d)
    3. Modify /etc/pam.d/login and add this line before account system-auth line
    4. account    required     pam_access.so
  4. Modify /etc/pam.d/sshd and add this line before “account include password-auth”
    1. account    required     pam_access.so
    2. Restart sshd
    3. Service sshd restart
  5. Set temp password for user1
    1.  # passwd user1
  6. Test login from server1 and server2
  7.  Should be able to login with the password.
    1.  a. [user1@server1 ~]$ ssh user1@server2
  8. Test login from some other linux box and this should fail.
    1. [serverX@web]$ ssh user1@server1
    2. Kernel \\r on an \\m
    3. user1@server2 password:
    4. Connection closed by server


Friday, March 20, 2015

OpenStack Sandbox Available

For those wanting to learn more about OpenStack, there is a new free way to try it out.  http://trystack.org/ is the OpenStack Sandbox. It's great for learning about openstack and best of all it's free! That's right it's free. Just join their facebook group to request a free account.   They state to 'Remember that it is a 'Testing Only' sandbox.

So what are you waiting for, get out there and try OpenStack at http://trystack.org/


Thursday, June 5, 2014

OpenSSL Heartbleed Again

The OpenSSL published another advisory today for people to update their openssl. Red Hat has also put an Advisory out


  • http://www.wired.com/2014/06/heartbleed-redux-another-gaping-wound-in-ssl-uncovered/?mbid=social_fbhttp://www.wired.com/2014/06/heartbleed-redux-another-gaping-wound-in-ssl-uncovered
  • https://rhn.redhat.com/errata/RHSA-2014-0627.html
  • https://www.redhat.com/archives/enterprise-watch-list/2014-June/msg00009.html
Please update your Red Hat servers. 

Quick satellite note, just to sync up your erratta only run the following command:
  • # satellite-sync --step=errata

Friday, May 16, 2014

How to Check Java Heap

Just some quick tips on checking the java heap.

You can get the process id from ps or use jps -l to list it.

jmap, jstat and jconsole are very good tools for finding out more about your jvm.

Check Heap size and details memory usage.
  • jmap -heap <jvm proc id> 
Check Max Settings
  • # ./jmap -heap 14272 |grep Max
    • Attaching to process ID 14272, please wait...Debugger attached successfully.Server compiler detected.JVM version is 23.3-b01   MaxHeapFreeRatio = 70   MaxHeapSize      = 1610612736 (1536.0MB)   MaxNewSize       = 17592186044415 MB   MaxPermSize      = 536870912 (512.0MB)
Other Java Memory Tips 

Check Java Process ID 
  •  ./jps -l 

Use jstat to See GC 
  • ./jstat -gcutil <jvm proc> 10 1 

Output Info 

Here is a list of acronyms used in the above output. 
  • S0 Survivor space 0 
  • S1 Survivor space 1 
  • E Eden Generation 
  • O Old Generation 
  • P Permanent Generation 
  • YGC Young GC Count 
  • YGCT Young GC time 
  • FGC Full GC Count 
  • FGCT Full GC time 
  • GCT Any GC time 
--- 

How to Find Age of a Process

If you need to know how old a process is or how long a process has been running you can find it very easily with ps and stat.  First find the PID of the process you'd like to know how long it's been running. In this example we will use ntp.


  • $ ps -ef |grep ntp
    ntp      62446     1  0  2013 ?        00:01:19 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g
Set PID
  • # PID=62446
Then just take the PID and run stat on the PID in the /proc directory
  • # stat /proc/$PID
  • File: `/proc/46448'
  • Size: 0               Blocks: 0          IO Block: 1024   directory
  • Device: 3h/3d   Inode: 48373597    Links: 7


Access: (0555/dr-xr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2014-02-20 15:28:34.229115802 -0600
Modify: 2014-02-20 15:28:34.229115802 -0600
Change: 2014-02-20 15:28:34.229115802 -0600


  •  Another way to view time of process

    •  ps -eo pid,etime | grep $PID


    Tuesday, May 13, 2014

    How to Extend LVM Swap Partition

    How to Extend LVM Swap 


    1. Turn off swap 
      1.  swapoff /dev/mapper/vg_spacewalk-lv_swap  
    2. Resize Swap LVM Partition 
      1. [root@spacewalk /]# lvresize -L 5G /dev/mapper/vg_spacewalk-lv_swap   Extending logical volume lv_swap to 5.00 GiB   Logical volume lv_swap successfully resized  
    3. Make swap again 
      1. [root@spacewalk /]# mkswap /dev/mapper/vg_spacewalk-lv_swap mkswap: /dev/mapper/vg_spacewalk-lv_swap: warning: don't erase bootbits sectors         on whole disk. Use -f to force. Setting up swapspace version 1, size = 5242876 KiB no label, UUID=b5b26e00-dfb5-4767-bfac-985d125c8331  
    4. Turn swap back on 
      1. [root@spacewalk /]# swapon -v /dev/vg_spacewalk/lv_swap swapon on /dev/vg_spacewalk/lv_swap swapon: /dev/mapper/vg_spacewalk-lv_swap: found swap signature: version 1, page-size 4, same byte order swapon: /dev/mapper/vg_spacewalk-lv_swap: pagesize=4096, swapsize=5368709120, devsize=5368709120  
    5. Check swap size 
      1. [root@spacewalk /]# swapon -s Filename                                Type            Size    Used    Priority /dev/dm-1                               partition       5242872 0       -1  
      2. [root@spacewalk /]# free -m              total       used       free     shared    buffers     cached Mem:          1877       1775        101          0         25        285 -/+ buffers/cache:       1464        413 Swap:         5119          0       5119

    Thursday, February 27, 2014

    How to Sign Packages for Custom Satellite Channel

    This page describes how to sign or resign packages (RPM's) from Third Party or custom rpm's and add them to custom channel. 

    1. Create GPG Key for Custom Packages 
      • gpg --gen-key   (if having problem us rng package - see SpaceWalk commands  ) 
        • follow instructions How to Create GPG Key on Virtual Machine 
          • yum install rng-tools 
          •  sed -i 's,EXTRAOPTIONS.*,EXTRAOPTIONS="-r /dev/urandom",' /etc/sysconfig/rngd  
          • service rngd start 
          • gpg --gen-key  
      • use gpg --list-key to show key  
    2. Retrieve or Export your public key 
      • # gpg --export -a myco-gpg > myco-pubkey.txt  
    3. Copy the key to PUB directory on Satellite 
      • # cp myco-pubkey.txt /var/www/html/pub/MYCO-PUB  
    4. Copy the GPG key into /var/www/html/pub on the Satellite Server so that existing servers can access it  using:\ 
    5. Upload the key to Satellite/Spacewalk 
      • go to Systems > Kickstart > GPG & SSL Keys 
      • click on create new stored key/cert 
      • Type in a description, and upload the file, by clicking create key 

    6. Upload RPM to Satellite/Spacewalk server temporary location.  
    7. Create or edit ~/.rpmmacros file as follows, where number is 2nd number shown from gpg --key-list 
      • .rpmmacros file 
        • %_signature gpg  
        • %_gpg_name B7085C8A 
      • rpm --resign package-name-1.0-1.noarch.rpm 
      • rpm --checksig -v package-name-1.0-1.noarch.rpm   
    8. Use rhn_push to push package to channel 
      1. rhn_push /tmplocation/*.rpm --server=https://mysatelite/APP  -a -c=mycustomchannel -u MYUser -p MyPass -c mycustomchannel 

    9. Add Custom Channel to your Master Activation Key and then add the packages you want to install in packages section. 
    10. or add gpg to your kickstart profile. Go to Kickstart > Profiles, MyProfile > System Details > GPG and check the MYCO-PUB gpg key, then click Update Keys 

    Bash - Send Email Reminder

    This script will send email reminder to admins

    #!/bin/sh 

    # Simple Script that runs at 8AM every 90 Days and sends email to admins 
    #to remind them to change the root password. 

    # 
    /usr/sbin/sendmail todd.walters @  myDom.com < /home/twalters/scripts/Reminder.htm 

    Exit 


    ------------------------------------------------------------------------------------------------------ 


    Reminder HTML Page 


    To: Admins@mYDom.xom 
    Subject: Reminder: Time to Change Root Password 
    Content-Type: text/html; charset="us-ascii" 

    <html> 
    <body> 
    <h2>90 DAY PASSWORD REMINDER<br></h2> 
    </br> 
    <h3>The root user password must be changed every 90 days</h3> 
    <p></p> 
    For more instructions see: <a href="http://MyOneNote/Linux%20Library/Linux%20How-To%20Documents/How%20To%20Change%20Root%20Password.aspx">How To Change Root Password</a>  
    </body 
    </html 

    How to Create F5 Monitor, Node, Pool, and Virtual Server


     
    Part I: Create Monitor  
    1. Login to F5 ( open additional tab, if needed, to copy settings from another item) 
    2. Create Monitor (for SomeApp) as needed, only need 1 monitor per app, not env. 
    3. Click on Monitor > +   
    4. On General Properties page, enter Name, Description, Type ( choose HTTP) 
    5. Under  Configuration in the Send String section, add the following 
      1. GET /<appname>/healthcheck\r\n 
    6. On Receive String section add Health: OK 
    7. Leave rest at default settings and click Finished  
    Part II: Create Node (as needed)  
    1. To create new node, click on Local Traffic > Nodes > Node List > + 
    2. Fill in the following information in the General Properties section 
      1. Name:  Server short hostname, ie devXXX 
      2. Address:  IP Address for node, ie 192.168.100.X 
      3. Description:  <hostname> <appname> ie srvXXX-Application1 
    3. In the Configuration Section, fill in the following 
      1. Health Monitor:  Node Specific 
      2. Select Monitor:  Choose icmp from available list and move to Active 
      3. Leave rest of settings at default and click on Finished  
    Part III:  Create Pool  
    1. To create new Pool, click on Local Traffic > Pools > Pool List + 
    2. Fill in the following information in the Configuration Section 
      1. Note: SomeApp uses <env>service_<app>_<port> as name and ports start at somePort# and increase by XX.  
      2. example for app tms:  devservice_app_port#    
      3. Name:  <env>service_app_port 
      4. Description:  <Env> Web Service SomeApp <App> 
      5. Health Monitors:  Add http1.1 or Health Check for App (if they have it) to Active 
    3. In the Resources section add the following information 
      1. Load Balancing: Leave as default Round Robin 
      2. Click on Node List and add Node you created above in Part II 
      3. Set the service port, usually 8080 for tomcat. 
      4. Click Add then click Finished 

    Part IV: Create Virtual Server   
    1. Create new Virtual Server, click on Virtual Servers > Virtual Server List + button 
    2. Fill in the following information in the General Properties section. 
      1. NOTE:  name follows same format as Pool name for service, ie <env>service_<app>_<port> 
      2. Name:  <env>devservice_<app>_<port> 
      3. Description: ENV APP VIP 
      4. Source: 0.0.0.0/0 
      5. Destination: IP Address assigned  for VIP, see wiki 
        1. 192.168.100.200 (for dev) 
    3. Fill in the following information for Configuration (Click Advanced) 
      1. Leave all as default unless specified below 
      2. Protocol profile (Client) :              service-tcp-profile 
      3. HTTP Profile:     http-xfwd 
      4. VLANS and Tunnels                         
        1. Enabled On 
        2. Select vlan123 
    4. Fill in the following information for the Resources section 
      1. Default Pool: Choose the Pool Created above to match the app 
      2. Click on Finished to complete 

    Part V: Sync Configuration   
    1. To sync configuration to second f5 node click on ‘Changes Pending’ in upper left of browser 
    2. Click on the (self) f5 that you are working on under the Devices section 
    3. Make sure Sync Device to Group is selected under Sync Options 
    4. Click on Sync    
    5. Repeat all steps above for each environment and sync afterwards.