Showing entries 1 to 10 of 14
4 Older Entries »
Displaying posts with tag: Linux Tips (reset)
MySQL PAM and Active Directory authentication

How-To configure your MySQL to use PAM and/or Active Directory authentication with percona-pam-authentication plugin. Continuing articles about Two-Factor authentication or integrating Linux services with Active Directory, this How-To is one of my recent works that I have done these days, so I hope it may help the community with this guide to configure MySQL with PAM and subsequently using Active Directory to authenticate. If you are new here, please refer to SSH Two-Factor authentication, which explains how to install likewise and integrate your Linux with AD. However, we will have few exceptions to get MySQL working with PAM authentication.

Before you continue, please make sure that you have MySQL 5.5.16 or a newer version, otherwise it can …

[Read more]
Connecting your Linux to a Cisco AnyConnect (SSL) – part 3

Hi there !

 

This is the final part of using openconnect  - You can check the older ones below:

http://www.heitorlessa.com/connecting-your-linux-to-a-cisco-anyconnect-ssl-part-1/

http://www.heitorlessa.com/connecting-your-linux-to-a-cisco-anyconnect-ssl-part-2/

 

As mentioned previously, we will be covering here:

  • How to create a script to monitor such VPN using ICMP, and restart that VPN if it is down

 

I would say, this is very straight forward and does not require much knowledge, so we are going to follow the same procedure as part 2 – Show the script in parts and then a …

[Read more]
Connecting your Linux to a Cisco AnyConnect (SSL) – Part 2

Hey you!

As said in the part 1 of this article, I will be covering here:

  • How to create a openconnect init script

So, concerning the init script I will be posting parts of the script first, and then will put a link for download at the end.

First of all, we need the shebang (#!/bin/bash) and then global variables that will be used along the script:

# Path variables
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# VPN Variables
IFACE="sslvpn"
VPN_USER="vpn_user"
VPN_HOST="sslvpn.yourdomain.com"
VPN_PASS="vpn_password"
PID="/var/run/openconnect.pid"
TEMP_LOG="/tmp/status.txt"
INFO="Usage: $(basename "$0") (start|stop|status|restart)"

You can also define most of these options in a …

[Read more]
[Bash] Performing array intersection with Bash

I am currently working on a project to deploy new website builds to a
small number of servers. I needed something simple and reliable that could
be built in a very short period of time. I decided to whip something up in
bash with the intent of refining it in Python later.

As I began to write this code, I realized that it probably would have been
quicker to do it in Python from the start. I decided to stick with bash as
somewhat of an academic exercise. The vast majority of these deployment
scripts were trivial; check the code out of git, create a manifest, package
it up, spew it to the servers, etc, etc. The problem came during the last
step. We decided to use a symlink to point to the active build out of a
number of builds that could be available on the server at any given time.
Since all of our servers should be running the exact same version of the
build, it …

[Read more]
How do you print number of files for each folder in a directory [Linux]

I have been annoyed by the fact that I couldn’t easily print file count for all of the folders in certain directory.  Most of the time I just want to see what space each folder is using (du -hs *) but there are times when I need to know how many files are in each folder (checking cache folder, session folders etc).   So I whipped together a command line which does just that for me:

for i in `find -maxdepth 1 -type d`; do  echo -n $i " ";find $i|wc -l; done

I am sure there are many different ways to show file count for each folder in a directory and I am curious to see what people do so please do post comments with what you do.

Above command is pretty simple and can be expanded to do whatever you need.  For example, you can throw it into a bash script and be able to pass parameters.  For example:  count_files /home/  In this case your command line would …

[Read more]
Telnet: shell script to issue commands to telnet session.

This is a quick post to show how one can issue commands to telnet session from a shell script or command line with out going into interactive mode. I use this to get stats from our memcache servers or issue a flush_all via telnet from a script/cron.

So without further delay, following command will telnet to local memcached server on port 11211 and issue one of the memcached commands, stats

(sleep .5;echo stats) | telnet localhost 11211
You may have to play with the sleep timer to get it to work for your environment but in our .5 was the sweet spot. Good luck and let me know if you have another shell command. Obviously we can do this from perl, php, python, etc but the beauty of this is that you do not need any other dependencies plus its a very short command. …

[Read more]
SVN: How do you use svn command line on Windows with ssh tunneling?

If you ever used svn command line, you know it is not optimal to type in your password every time you do checkout, checkin, info, etc.  In linux world, it is very easy to setup keys to get around this.  Of course in the world of Windows it is not as easy.  Here are the steps you need to follow to get private/public keys working with your SVN under Windows using ssh tunneling.

Assumptions:  you will be connecting as user “root” to svn server located at “10.0.0.1”.  All your files will be saved at c:\ including your svn command line utility

First we will have to generate a key.  We can accomplish this by using a free utility called …

[Read more]
sshfs: How do you install sshfs and fuse? [CentOS/Linux/Redhat]

One may wonder what is sshfs and why would you want it?  Well simply put, sshfs allows you to mount another server’s filesystem into a folder on your local system which in the background is doing ssh commands and transfers.  As a mounted folder, you are able to move about and copy files back and forth as everything was on local server.  As you can see this makes it very easy for you to work with files on multiple servers.

Note:  you only have to do the following installations on the server where you are doing the mounts on.

Let us download and install the filesystem framework which is a requirement for sshfs called fuse.

wget http://voxel.dl.sourceforge.net/sourceforge/fuse/fuse-2.7.4.tar.gz
tar zxpfv fuse-*.gz
cd fuse*
./configure

If you get the following error, you will either have to point to the location of the kernel source or …

[Read more]
Linux: How do you find out what your server’s outgoing ip is?

There are many times when I needed to find out my outgoing (or external) IP for the servers which are behind load balancers or firewalls.  I used to just login to another external server from the server in question and find out by looking at “who” what my external ip is.  Even though it works and I am so used to it, today I decided to figure out a more graceful way of finding my outgoing ip.  As most of us already know, whatismyip.com is the quickest way to find out your outgoing ip from the browser.  So I decided to use the same way on the servers.  So I issued a wget:

wget http://www.whatismyip.org

Well that does the trick.  But being lazy as I am, I did not want to have to cat the output file to find out the ip (plus there is no point of creating extra files and doing extra work to remove them).  …

[Read more]
Quick tip: how do you rename all files so spaces are converted to underscores?

My friend today asked me how to convert all spaces in filenames under a specified directory to underscores. Also, at the same time lowercase all of the filenames. Here is a quick script to do what is needed. Let us start with creating some test data in a temp directory:

mkdir temp
cd temp
touch Foo FooO "Foo Bar" "FOO BAaR"
\ls | while read -r FILENAME
do
mv -v "$FILENAME" `echo $FILENAME| tr ' ' '_'| tr '[A-Z]' '[a-z]'`
done

Note:  I intentionally have slash in front of ls (\ls).  \ls means that we want to make sure there is no ls alias overwriting our command. This is needed if your system has alias setup to display ls in a different way instead of default listing.  mv -v shows us the filenames being renamed as your script goes through the whole dir.  Your output should be like:

`Foo' -> `foo'
`FOO BAaR' -> …

[Read more]
Showing entries 1 to 10 of 14
4 Older Entries »