AWS S3 Backup guide 1, bash script

If you don’t have ( or don’t want ) aws-cli installed you can upload files under 5gb with the following script:

#!/bin/bash
# Size limit of 5gb, if you need to upload a bigger file use AWS Cli tools
# $1 Must be the full path of the file
file=$(basename $1)

# S3 authentication information
bucket="<NameOfTheAwsBucket>"
s3Key=""<AWSAccessUser>"
s3Secret="<AWSAccessKey>"
awspath=s3.amazonaws.com
resource="/${bucket}/${file}"

# as we are uploading a backup the need to be a tar archive
contentType="application/x-compressed-tar"
dateValue=$(date -R)
stringToSign="PUT\n\n${contentType}\n${dateValue}\n${resource}"


# Signature magic :)
signature=$(echo -en ${stringToSign} | openssl sha1 -hmac ${s3Secret} -binary | base64)

curl -X PUT -T "${file}" -H "Host: ${bucket}.s3.amazonaws.com" -H "Date: ${dateValue}" -H "Content-Type: ${contentType}" -H "Authorization: AWS ${s3Key}:${signature}" https://${bucket}.${awspath}/${file}

 
Continue reading “AWS S3 Backup guide 1, bash script”

Force apt-get to use IPv4

If you are having problems with apt and IPv6 a temporary solution is to use the option ‘Acquire::ForceIPv4=true’ by appending ‘-o Acquire::ForceIPv4=true’ at the end of the apt command.

apt-get update -o Acquire::ForceIPv4=true

 
If you want a more permanent solution you can disable the usage of IPv6 with apt altogether with:

echo 'Acquire::ForceIPv4 "true";' | tee /etc/apt/apt.conf.d/99force-ipv4

 

Sources:

https://unix.stackexchange.com/questions/9940/convince-apt-get-not-to-use-ipv6-method

Disable IPv6 Centos/Debian/Ubuntu

To completely disable IPv6 on your Linux system, side note you shouldn’t but it’s your choice, you can do so simply editing the 99-sysctl.conf file at the location ‘/etc/sysctl.d/99-sysctl.conf’
 
Copy and paste the following 3 lines at the bottom of the file.

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

 
After editing the file you need to then reboot the machine or run the following command as root

sysctl -p

To verify that you have ipv6 disabled you can run

Continue reading “Disable IPv6 Centos/Debian/Ubuntu”