How Do You Install libyaml on a Red Hat Derivative of Linux?

Problem scenario
You are using a RedHat derivative of Linux.  You get an error about libyaml not being installed (e.g., when a dependency of Suricata is unmet).  You tried to install libyaml-devel, but it did not work.  What should you do?

Solution for RHEL
If you are using RedHat run these two commands:

sudo yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
sudo yum -y install libyaml-devel

Solution for CentOS/Fedora

If you are using CentOS or Fedora, go here to get the package you need.

Troubleshooting and an FYI Regarding OpenSSH

Problem scenario #1
You try to SSH to a Windows server with OpenSSH.  You get "Permission Denied."
Solution
Go to the Windows server.  Go to Server Manager -> Tools -> Computer Management -> Users and Groups.  Double click on the user you are trying with.  Uncheck "User must change password at next log on."  This setting will not allow an SSH connection to happen.

Problem scenario #2
ssh-agent service is running on a Windows server with OpenSSH.  From a Linux sever you use this command: nmap -p 22 x.x.x.x #where x.x.x.x is the IP address of the Windows server.  You find that the port is closed (but not filtered).  You cannot SSH to the Windows server.  What is wrong?
Solution
From a PowerShell prompt, run this: start-service sshd
Now port 22 will show as open if you try the nmap command again.  Now you should be able to ssh to the Windows server.

FYI
These directions have a variation of this step of running "start-service sshd" as optional.  It is not an optional step.

How Do You Create an RSA Private/Public Key Pair with OpenSSH in Windows?

Problem scenario
You have OpenSSH installed on a Windows machine.  You are in a PowerShell prompt as Administrator in the directory where the ssh-keygen.exe file is.  You run this:  .\ssh-keygen.exe -t rsa
You get "Generating public/private rsa key pair."  No new prompt appears.  It hangs (or stalls) for a long time.  You wait, and find that it is essentially frozen.  You control-c to interrupt it and move on.

You are in a PowerShell prompt as Administrator in the directory where the ssh-keygen.exe file is.  You run this:  .\ssh-keygen.exe -t rsa -f C:\\Program Files\\OpenSSH\\Openssh-Win64\\newfile
No new prompt appears.  It hangs (or stalls) for a long time.  You wait, and find that it is essentially frozen.  You control-c to interrupt it and move on.

How do you generate a public/private rsa key pair?

Possible Solution #1
Open a cmd prompt. You do not need to do it as Administrator.  cd to the directory where ssh-keygen.exe is.  Use this command ssh-keygen -t rsa (with no .exe).  This creates a private/public key pair.

Alternative solution #2
Open a PowerShell prompt but not as administrator. Run this command: ssh-keygen -t rsa

Two Error Messages when Installing Gems On Linux

Problem scenario:  You are trying to use gem install, but you get an error like this:
"usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h"

Solution:  Install ruby-devel.  For RedHat deriviatives, you can find the rpm here.

=====================================================================================

Problem scenario:  You are running gem install *.gem, and you get 'ERROR: While executing gem ...
(Net::HTTPServerException) 407 "Proxy Authentication Required"'

Potential Solutions:  The server's Internet connection seems to be somewhat working (but not completely and not completely broken either).  Change your proxy settings.  Your proxy seems to be causing an issue.  It could potentially help to disable the proxy to eliminate Internet access.  It may help to reboot the server that you ran the gem install command on.

Using a rubyntlm script (http.rb), you get “connection refused.”

Problem scenario:  You modify this script to have a hostname, username, and password of a Windows server with IIS installed.  You add a "puts line" stanza on line 32 for debugging.  You try to run the script with ruby http.rb, but you get "connection refused."  

Possible solutions:  If you changed the port stanza in the http.rb file from 80, make sure there is no firewall blocking the port in the path to the Windows server.  Some port numbers will not be accessible by default on your Windows servers.  Assuming you leave the port to be assigned to 80, make sure there is nothing blocking it on the network or on the target Windows server.

Rubyntlm: Communication from a Linux Server to a Windows Server

Problem scenario:  You modify this script to have a hostname, username, and password of a Windows server on your network.  You add a "puts line" stanza on line 32.

You run the script but you get a message like this: "HTTP/1.1 404 Not Found error. "

Solution:  Make sure that the Windows server has IIS installed, make sure the server name you entered was correct, and make sure the Windows server is turned on.

This Command “gem install contint.gem” Hangs Forever

Problem scenario:  You are running gem install *.gem and it hangs.  This stalling appears to be a freeze.  You wait several minutes and nothing happens.  You are waiting for a message or a new prompt.

Solution:  Control-C to get out of it.  Try it again with the "-V" flag like this:

gem install contInt.gem -V

# This time be patient.  Sometimes these commands can take more than 10 minutes to return a message.  The -V flag will provide messages (or more detailed messages) as to the problem you are experiencing.  The -V flag and be placed immediately after the "gem install " or at the very end.  The -V flag is interchangeable with the "--verbose" flag.

Unexpected PowerShell Closures and Controlling the Flow of PowerShell Scripts

Problem scenario:  You PowerShell or PowerCLI window keeps exiting automatically when you run a script.  You find that RAM and CPU are not constrained.  
Root cause: Human error.
Solution:  Look for the "exit" or the "Exit-Pssession" commands.  These can close PowerShell's ISE or PowerCLI.  You may need to eliminate these commands or use a different keyword.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Problem scenario:  You want to use a for-each loop in PowerShell, you do not want the script to cause the interactive PowerShell window to close, and you want the action portion (in braces {}) to run only once.  What do you do if you do not want to re-write the function to use an "if" or a "while" loop?

Solution:  Use the "break" or "return" key word as the last line in the action clause.

foreach ($cont in $integration) {
   write-host $cont
   return  # or break
}

Return will return the control of the PowerShell interpreter to the previous location before entering the foreach loop.  This is particularly significant when you have functions.  Break can be called with an accompanying label.  For example,
this code would not just interrupt the foreach clause but the PowerShell interpreter would start parsing the ":contInt" section of code:

:contInt if ($foo -eq 289) {
     while ($foo < 505) {
        foreach ($cont in $integration) {
           write-host $cont
           Break :contInt    
         }
      }
}

In the future we want to re-write these directions to use write-verbose instead of write-host. We want to warn people that write-verbose is recommended instead of write-host (according to this posting).

How do you install Jenkins on a RedHat Linux server without an Internet connection?

Problem Scenario 
(If you have an internet connection, see this posting.)  In trying to install the different .rpms (e.g., on CentOS/RHEL/Fedora) for Jenkins you get errors.

For example, here is one command you might try:
yum localinstall springframework-aop-3.2.15-3.fc24.noarch.rpm

This above command may result in an error like this:
"Requires: mvn(org.springframework:spring-beans) = 3.2.15.RELEASE ... Requires: mvn(org.springframework:spring-core) = 3.2.15.RELEASE"

Here is another command you might try: 
yum localinstall jenkins-instance-identity-1.4-5.fc24.noarch
You might see an error like this:
"Requires: mvn(org.bouncycastle:bcpkix-jdk15on)"

To summarize the problem there are numerous dependencies. Installing Jenkins piece-by-piece is tedious.  How do you install Jenkins without internet access?

Solution
Get an .rpm file from this link: http://pkg.jenkins-ci.org/redhat-stable/ 
One of the files will allow for offline (or standalone) installations.

If you need assistance installing plugins without internet access, see this posting.

How Do You Install Pywinrm Without Pip and Without a Yum Repo?

Problem Scenario:  You have CentOS (or a RedHat derivative) and Python is installed.  You want to install pywinrm.  When using Python and Python packages you get this error "gaierror ... 'Temporary failure in name resolution'))."  How do you install pywinrm without pip and without a relevant yum repo?

Root cause:  It can be caused by excessive open connections.  A reboot could fix the problem.  

Solution:  Get the RPM file for pywinrm and its two dependencies.  To do this run these four commands if you have internet access on the Linux machine:

wget ftp://ftp.icm.edu.pl/vol/rzm5/linux-opensuse/repositories/devel:/languages:/python/openSUSE_13.2/noarch/python-pywinrm-0.0.1.99-1.1.noarch.rpm

wget ftp://mirror.switch.ch/pool/4/mirror/fedora/linux/updates/23/armhfp/p/python-isodate-0.5.4-1.fc23.noarch.rpm

wget ftp://ftp.icm.edu.pl/vol/rzm5/linux-fedora-secondary/releases/23/Everything/ppc64/os/Packages/p/python-xmltodict-0.9.0-2.fc23.noarch.rpm

# If the links don't work, find other hosting providers at http://rpm.pbone.net.  If you do not have internet access, download the files to a workstation. Then transfer them to the Linux machine.

yum localinstall python*rpm

# If you prefer, use "rpm -ivh python*rpm"

If you do not have pip installed, have no direct connection to the Internet and no yum repo configured, this solution will still work.