EC2 Plugin Jenkins with IAM Role

Use this for Jenkins and Slave it self

 

Important is am:PassRole

 

https://aws.amazon.com/blogs/security/granting-permission-to-launch-ec2-instances-with-iam-roles-passrole-permission/

https://engineering.aol.com/bits/574213645bf6233aab3f2c71/cross-account-aws-deploployments-in-jenkins

https://wiki.jenkins-ci.org/display/JENKINS/Amazon+EC2+Plugin

{
“Version”: “2012-10-17”,
“Statement”: [
{
“Action”: [
“ec2:DescribeRegions”
],
“Effect”: “Allow”,
“Resource”: “*”
},
{
“Action”: [
“ec2:CreateTags”,
“ec2:DescribeInstances”,
“ec2:DescribeKeyPairs”,
“ec2:GetConsoleOutput”,
“ec2:RunInstances”,
“ec2:StartInstances”,
“ec2:StopInstances”,
“ec2:DescribeTags”,
“ec2:DeleteTags”,
“ec2:DescribeRegions”,
“ec2:DescribeAvailabilityZones”,
“ec2:DescribeSecurityGroups”,
“ec2:DescribeSubnets”,
“ec2:DescribeImages”,
“iam:PassRole”,
“ec2:TerminateInstances”
],
“Effect”: “Allow”,
“Resource”: “*”,
“Condition”: {
“StringEquals”: {
“ec2:Region”: “eu-central-1”
}
}
}
]
}

Linux Login SSH Fingerprint

Some Person was login to your Linux VM? You have more than 10 people with a login to the System. In var/log/auth.log(Ubuntu) you see a fingerprint from ssh key.

cat ~/.ssh/authorized_keys | xargs -n1 -I% bash -c ‘ssh-keygen -l -f /dev/stdin <<<“%”‘

 

2048 32:3s:32:91:a2:f5:1c:3c:25:6e:05:f2:25:24:5b:01  person1@example.com (RSA)
4096 32:3s:32:91:a2:f5:1c:3c:25:6e:05:f2:25:24:5b:02 person2@example.com (DSA)
2048 32:3s:32:91:a2:f5:1c:3c:25:6e:05:f2:25:24:5b:03 person3@example.com (RSA)
4096 32:3s:32:91:a2:f5:1c:3c:25:6e:05:f2:25:24:5b:04 person4@example.com (RSA

 

Now you become a list with all Fingerprints and Name of your login users.

Find it out which person have login to your system….

grep “32:3s:32:91:a2:f5:1c:3c:25:6e:05:f2:25:24:5b:03” /var/log/auth.log

 

Some Code Snipes found here

http://serverfault.com/questions/413231/how-to-get-all-fingerprints-for-ssh-authorized-keys2-file

Progressive/interlacd jpeg on Linux

 

How to install jpegtran

apt-get install libjpeg-progs

 

Script found here


#!/usr/bin/env bash
function optimize
{
echo $1
filesize=`stat –format=%s "$1"`
if [[ $filesize -lt 10000 ]]; then
jpegtran -copy none -optimize "$1" > "$1.bak"
echo "pet"
else
jpegtran -copy none -progressive "$1" > "$1.bak"
echo "grand"
fi
if [[ $filesize -lt `stat –format=%s "$1.bak"` ]]; then
echo "compression plus lourde"
rm "$1.bak"
else
echo "good!"
mv "$1.bak" "$1"
fi
}
find . -name '*.jpg' -type f -print0 |while read -d $'\0' i; do optimize "$i"; done

#!/usr/bin/env bash

function optimize
{
echo $1
filesize=`stat –format=%s “$1″`
if [[ $filesize -lt 10000 ]]; then
jpegtran -copy none -optimize “$1” > “$1.bak”
echo “pet”
else
jpegtran -copy none -progressive “$1” > “$1.bak”
echo “grand”
fi

if [[ $filesize -lt `stat –format=%s “$1.bak”` ]]; then
echo “compression plus lourde”
rm “$1.bak”
else
echo “good!”
mv “$1.bak” “$1”
fi
}
find . -name ‘*.jpg’ -type f -print0 |while read -d $’\0′ i; do optimize “$i”; done

Or you can use also image magic

find . -name ‘*.jpg’ -exec convert -strip -interlace Plane -quality 80 {} {} \;

Check if it is interlaced

find . -name ‘*.jpg’ | xargs identify -verbose *.jpg | grep Interlace

Mount your bucket with s3fs

 

s3fs -o use_cache=/tmp/cache mybucket /mnt/s3

 

how to install

https://www.robusta-hosting.eu/en/blog/development/2015/04/install-s3fs-ubuntu-1404-lts