Wednesday, August 30, 2017

DavMail, Thunderbird and Systemd..

So I can't recall if I posted about this or not but since switching full time to Fedora I've had to get creative with email clients.  Since Evolution is clunky and rather ugly I decided to brave the DavMail world with Thunderbird.

Now for quite a while I've been suffering through DavMail just quitting on me.  Nothing gets logged anywhere, the pid just dies. However today in #systemadmins I tossed out a question and it was fielded by a guy who I'd consider quite the senior in the whole *nix/SysAdmin world.  Dude took less than 20 minutes and had me a working systemd.service file that will run automagically and restart if it happens to die, oh and get this.. it will LOG too! *giggle*

Here's the file for those interested:

[Unit]
Description=DavMail Exchange Gateway
Requires=network.target
After=network.target
[Service]
Type=simple
RemainAfterExit=no
#ExecStart=/usr/bin/davmail /etc/conf.d/davmail.properties
#ExecStop=killall davmail
Environment=BASE=/path/to/davmail-linux-x86_64-4.8.0-2479/
Environment=PROPERTIES=/path/to/.davmail.properties
ExecStartPre=/usr/bin/bash -c "for i in $BASE/lib/*; do /usr/bin/systemctl set-environment CLASSPATH=${CLASSPATH}:$i ; done"
ExecStart=/usr/bin/java -Xms1G -Xmx1G -Djava.awt.headless=true -XX:ErrorFile=/tmp/davmail_errors.log -XX:-HeapDumpOnOutOfMemoryError -Dsun.net.inetaddr.ttl=60 -cp ${BASE}/davmail.jar:${CLASSPATH} davmail.DavGateway ${PROPERTIES}
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target



Wednesday, July 26, 2017

Python 3 + Paramiko UPDATE

I can hear the voice over from Unreal Tournament. back in the day, "MU MU MU MULTIKILL!"

I figured out the correct syntax for my SSH/paramiko script thus completing my second actual Python script.  WOOT. (With vast amounts of help from the guys in an IRC channel I frequent)

So my hangup on all of this boiled down to trying to use a Python2 command in Python3.. Ok well two instances of that: raw_input() was changed to just input().  And my print stdout() should have been print(stdout.read())
Once I got those values changed she ran like a well-oiled machine.  Here's what I've been working on:


import sys, paramiko, getpass


user = input("Username:") #Prompts for username#passwd = getpass.
getpass("Password for " + user + ":") #Prompts for password
key_file = input("Publickey full path:") #Prompts for full path to 
key file
name = input("Target Hostname:") #Prompt for target 
hostnamec
command = input("Enter target command:") #Prompt for 
remote command

#Calling the paramiko ssh function
ssh = paramiko.SSHClient() 
#Define value 'ssh' as calling the paramiko.sshclient
print('calling paramiko')ssh.set_missing_host_key_policy(paramiko.
AutoAddPolicy()) #Must come before connect line to add hosts 
to known_hosts#ssh.connect("name", username="user",
password="passwd")
ssh.connect(hostname = name, username = user, key_filename = 
key_file) # key_filename means to specify, 
pkey on the#other hand means to actually paste in the key text 
itself 
print('trying to connect')
ssh.invoke_shell()
stdin, stdout, stderr = ssh.exec_command (command)
print(stdout.read())
#ssh.close()

I will keep this, if anything as a paramiko snippet.  It works, it shows me how to SSH into a remote host and run a command.  At this early stage, I can't ask for much more.

Tuesday, July 25, 2017

Python + Paramiko = SSH unhappiness :(

Been reading the book, watching random YouTube videos on Python.. reading articles and blog posts. Figure one of the best ways to learn something is by doing, so I thought and thought and what's one of the most used parts of a script?

Connecting to a remote machine!

So I went with Paramiko as it seems to be the defacto SSHing inside Python .. thing.  Following examples is still tricky.  I created a new EC2 instance for this.. churned out a short script or snippet as I like to call it.  A paramiko_snippet on using the SSH client but am having issues sending remote commands.

I can connect, and invoke_shell() returns an active channel so I'm good there.

But when sending commands, 'channel.send('command')' returns nothing but a number.. in this case a 2.. next time I ran it gave me a 3.

Maybe it's some Python 2 versus 3 issue.  It's not clear yet, but my Google-Fu is strong and I will figure it out.

channel.send('ls')
2
channel.send('ls\n')
3

Thursday, July 13, 2017

Learning Python!

It's been a while since my last post.  Just been horribly busy with work and home stuff, and being in Montana it's damn hard to stay indoors!

Anyway for the past three weeks I've devoted myself to picking up a working knowledge of Python.  So far I like it!

The IRC channel I frequent is chock full of current|ex Amazon folks, Expedia, Disney, Mojo and a few other places that I'd consider 'Enterprise' level.  More than one handful of devops live in this channel so under a few actual, real DevOps Engineers I chose to start this adventure off with a book;

Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic.

It' easy to read and follow.  I typically read some while at lunch and spend nights watching the Udemy videos that follow 'Automate The Boring Stuff with Python'.  Once the Udemy videos are done I'm considering paying for a month of Lynda.com and checking out what they have.

In any case, why did I start this? After doing the whole sysadmin thing for almost 15 years I'm feeling stagnant.  I mean sure every time you change employers or introduce some new application you are learning new things.  And while I don't want to switch paths straight into development, I do really enjoy pulling together some code and forming something new with it.

Also under advisement from the crew I chose PyCharm as an IDE.  Absolutely love it!  Very intuitive, helpful, and damn easy to learn.  Discovered virtenv's the other day and last week I wrote my first actual script and used it at work!

Anyway I've got my eyes set on a new price in town which would come with a new title.  We'll see.

Thursday, May 25, 2017

Powershell Script: Remove Windows 10 Apps

Tired of all the bullshit apps that Microsoft bundles with Windows 10?  I know I am!

This is just a combination of the same stuff that can be found on MANY websites out there.  I just didn't want to create 15 individual .ps1's or copy/paste as many times.




Get-AppxPackage *xboxapp* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *soundrecorder* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *bingsports* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *windowsphone* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *people* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *onenote* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *bingnews* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *zunevideo* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *bingfinance* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *solitairecollection* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *windowsmaps* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *zunemusic* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *getstarted* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *skypeapp* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *officehub* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *windowscommunicationsapps* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *3dbuilder* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *feedback* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *bamboo* | Remove-AppxPackage
[void](Read-Host 'Press Enter to continue…'); Get-AppxPackage *eclipse* | Remove-AppxPackage



Feel free to pretty up the "Press Enter to continue..."

Monday, May 1, 2017

GitKraken....Linux/Windows/MAC GUI interface for your git needs. Very cool!

So after fighting git on the command line for a solid two weeks, the idiot I am never thought to search for a gui to this madness.  Google respectfully greeted me with a top spot: GitKraken.

Man it's neat, and VERY attractive to the eyeball. Granted I've been using it for all of 10 minutes but I already resolved my merge conflict!  Yeah!

Ok so being truthful, I'm positive anyone experienced enough with git could have not had the issues I did.. but trying to visualize all that is my git branches in my head did become tough.  Yeah purists will call me a wiener but I really don't care.  I'm loving me some GitKraken and I recommend it to all.. experienced or not this is a great tool for helping you work with your repo.

Thursday, April 6, 2017

Fedora 26 Alpha released!

(Taken from https://fedoramagazine.org/fedora-26-alpha-available-now/)

The Fedora Project is pleased to announce the immediate availability of Fedora 26 Alpha. The Alpha release is an important milestone towards the Fedora 26 release later this year.
You can download the Alpha versions of Fedora 26 Workstation and Fedora 26 Server from the pre-release pages of the Get Fedora website. Pre-release versions of the Fedora SpinsFedora Labs, and Fedora for ARM are also available.

Fedora Alpha releases are provided for Fedora users to try out the upcoming release. More importantly, Fedora engineers want you to file bugs against the upcoming release. The Fedora 26 Changeset page on the Fedora wiki provides a list of new features provided in Fedora 26.

Judging from what I've read on the changenotes.. the team has resolved quite a few issues and introduced new things that I think folks will like.

Fedora.. the Fedora community and arguably the best Linux distro out there.

So recently, (3 weeks back) I decided to volunteer my time and limited knowledge to the Fedora Infrastructure group.  The IF group is what keeps the many official Fedora websites going, as well as EPEL repos, Bugzilla reports, Fedora ISO/etc downloads and a host of other systems running in top shape.

I've learned to love Fedora, much like an ancient simian loves picking at grubs and berries.*

(Sorry I've been re-watching Deadwood, and I find myself talking in that fashion)

Anyways, So yeah at work I finally made the switch totally and I felt the need to give back.. what little I can.  Luckily for me the community and the IF group have no qualms taking on those with little experience, giving them tasks for perform while at the same time learning as they go.  Which is definitely my forte since whatever I learn from them can only help me at work and vice-versa.

Anyway I have been working on SOPs or Standard Operating Procedures for a couple sites with the group and hopefully my tasks will rise in both complexity and awesomeness.

Thursday, March 30, 2017

Pianobar.. Pandora for the Command-Line

First off I love this package!!  Not only is it cli -based, which is my 'deal' these days.  But it lets me skip songs, shelve them for a month, choose and create new stations... plus it does not time out asking if I'm still there.

https://github.com/PromyLOPh/pianobar  clone this guy down locally and get to listening to your favorite music!


Friday, March 10, 2017

BASH: change ownership of subfolders based on parent folder name

Sounds convoluted, and honestly I felt overwhelmed trying to figure out how to handle this programmatically.

So for the past few days I've been working on a new Cent7 server to replace an aged 6.6 vm.  This box sits in the DMZ and is used by various entities around the state to sftp certain txt files to.  So there are roughly 50 home directories.. each with sub folders and an ssh key.  So in an effort to *not* force the users to create new ssh keys I rsync'd the entire parent folder over.  First time I lacked the proper permissions and wound up creating the home folders but nothing underneath.

So long story short, I eventually was able to get the correct syntax down to rsync the /chroot/parent and all the individual home sub-folders to the new server WITH the two sub folders and the .ssh(which houses the authorized_key file).  EUREKA!

However now all the permissions were borked up.  My own local ssh user had taken ownership of the parents, and children in both user and group. DOH!  I was able to clean up the group side of things easily enough via: 'chown -R :group /*'  However the user side was trickier because the user side on the two sub folders needed to be owned by the user in question.  (Obviously) but luckily enough for me the home folder's names was the username entirely.  Lucked into this absolute gem:

Fix the path in Line 1, and you are golden!


for dir in /home/*/; do
    # strip trailing slash
    homedir="${dir%/}"
    # strip all chars up to and including the last slash
    username="${homedir##*/}"

    case $username in
    *.*) continue ;; # skip name with a dot in it
    esac

    chown -R "$username" "$dir"
done

Thursday, March 2, 2017

Fedora 25, Another Shot at a Linux Workstation - UPDATE #2

So a while back I posted complaints about DisplayLink and their (so far) unwillingness to offer up Linux drivers for distros other than Ubuntu.
Since then I have discovered that USB-C docks that utilize DisplayLink seem to work right out of the box.  Display, Ethernet, and usb-passthrough all work perfectly.

So the current plans are, once I'm satisfied that I can perform all my normal functions at work using Fedora and a Win10 vm, connect to all three VPN tunnels in both OS's and access all the files I need then it's time to acquire a dock.

:happy dance:

Wednesday, February 15, 2017

vCenter 6.0 Failed To Deploy .OVF

So today I ran into an issue where I was exporting to template, a Cent7 image from vSphere 5.5 and importing into version 6.0.

I exported successfully enough, which generated three files: cent7-base template.ovf, *.vmdk and *.mf.
I needed to get these files from our ESXi server in-house to the states datacenter across a semi-quick VPN tunnel.  So I was able to browse the datastore in 6.0 and upload the three files from my local machine.

1.58 hours later..


Done.  So feeling good about myself I went to import OVF Template only to have it fail roughly 5 seconds later.  The error was: _deviceimage-0.iso was not found

Puzzled.. wait how the hell was there an iso involv... oh crap.  I forgot to disconnect the pending/failed VMware Tools installer.  So being the curious lad that I am, I (on a guess) tried opening the ovf file using Notepad.. primarily because it was small and I figured it might hold config info.  Boy was I right!  The .ovf file is laid out like an XML.. I found one reference to an iso file.. specifically: vmware.cdrom.iso.  So I removed it and instead placed the following: vmware.cdrom.passthrough which I recalled was an option in the GUI.

Saving the file I re-tried teh import to have it complete successfully!  WOOT.

Friday, January 27, 2017

MobaXterm, Where have you been all my life?

MobaXterm... I discovered this beauty two weeks ago and I must say, wow.

At my 'new' job, (I emphasis that because I've been here 4 months now) anyway I support almost 40 various Linux servers and like 10 Windows machines.. all virtual of course.  But needless to say the majority of my time in in a terminal.

So anyway I started using SuperPutty like my co-worker, the other SysAdmin.  SuperPutty is alright, I mean it's got tabs, you can paste easily enough, saved links imported from Putty.  However I just had this feeling like I was missing out.  I mean its' 2017 FFS! There's better (i.e. more feature-rich and prettier) stuff out there.

So I went Googling and MobaXterm is the result.  It's so good that my boss today decided to buy a trio of licenses.

What do I love about it?  Well it did teh same as SuperPutty, it imported my saved sessions, it's got session tabs.. but it also supports connection ranging from ssh to sftp, serial, http, telnet, rsh, rdp, vnc, ftp, mosh, browser and more! It has what they call a 'graphical SSH browser' that sits along the left-hand side that allows you to browse the fille/folder structure.. even copy files to and from the host.  Or you can directly edit files within the same window.. This alone allowed me to ditch WinSCP!
Oh man.. and Syntax Coloring, there's typical Linux, Warnings/Errors, Cisco and  a couple more.  And what I noticed right off the bat, upon successful connection to a remote host you are presented with a window that tells you the following:
X11 Forwarding enabled?
SSH Agent?
How many Active SSH tunnels to this host
and the X11 Display IP

I'm not a paid spokesman by any means.. but damn this is one friggin awesome product!

MobaXterm
http://mobaxterm.mobatek.net/

Thursday, January 26, 2017

Rescan Linux VM guest for new vmdk w/o reboot

So recently at $work I've been handling a project to migrate production and test Oracle environments to new hardware on top of new vSphere as well.

So my job is corralling the DBA contractor, keeping him on par and whatnot.  Anyway this post isn't about that really.  The servers themselves are CentOS 7 with Oracle 12c, and in the name of Best Practices I've created 5 hdd's: OS, U01, U02, tmp and Backups.  So last night DBA requests another named U03 to house teh redo log files.  Ok sounds good, but this time I did not want to have to bounce the server to see the hew 'hardware'. So credit goes to: Vivek Gite @ here


echo "- - -" > /sys/class/scsi_host/host#/scan


Works like a friggin champ!  Of course this string returns nothing but a quick Fdisk -l shows that my sdf was found.

*drops mike*