banned by fail2ban on my own vps!

When using filezilla on Windows, literally I tried connection many times/ways and it didn’t work. I ended up being banned by fail2ban/firewall. Rebooting the vps didn’t help. Hence, I needed to manually un-ban myself.

It actually happened again, so I think it’s time for writting it here in case others folks have same issue.

My steps:

  1. First, I tried to confirm if my IP was blocked, and this command shows list of IPs current blocked/ban: sudo iptables -L -n
  2. Find public ip address. I was not sure what my public IP address was, so In computer where I do ssh access, Google for the following to obtain public address (currently blocked by firewall/fail2ban):     my public ip address
  3. Find the jail name. I was not aware how to do this, but in fail2ban.org site documentation I found this command which lists all current jails:  sudo fail2ban-client status
  4. With information from point 1 and 3, I ran the following command to un-ban my ipaddress:  sudo fail2ban-client set sshd unbanip 999.999.999.999
  5. Try ssh access and it worked this time.

For sure I will come back to this guide :p

 

Docker – error on docker version

Today, I tried to run docker installed on my Windows 7 (Docker toolbox) and it’s throwing an error :*(.

Running following Docker command:

MINGW64 ~
$ docker version
Client:
Version:      1.12.6
API version:  1.24
Go version:   go1.6.4
Git commit:   78d1802
Built:        Wed Jan 11 00:23:16 2017
OS/Arch:      windows/amd64
An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/version: open //./pipe/docker_engine: The system cannot find the file specified.

 

Also, running the following command throws same error:

MINGW64 ~
$ docker info
An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/version: open //./pipe/docker_engine: The system cannot find the file specified.

 

However, running following commands returns good results:

$ docker-machine start default
Starting "default"...
Machine "default" is already running.

$ docker-machine env default
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="C:\Users\userName\.docker\machine\machines\default"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell:
# eval $("D:\Program Files\Docker Toolbox\docker-machine.exe" env default)

 

After googling, I found this link:

https://github.com/docker/docker/issues/22338

 

So, to fix it, we need to run the following in my git-bash:

eval $("D:\Program Files\Docker Toolbox\docker-machine.exe" env default)

 

Then try again the following:

docker version

And it should it should be good now:

$ docker version
Client:
Version:      1.12.6
API version:  1.24
Go version:   go1.6.4
Git commit:   78d1802
Built:        Wed Jan 11 00:23:16 2017
OS/Arch:      windows/amd64

Server:
Version:      1.12.6
API version:  1.24
Go version:   go1.6.4
Git commit:   78d1802
Built:        Wed Jan 11 00:23:16 2017
OS/Arch:      linux/amd64

 

Life is good again 😀

happy coding.

Coding Python using Docker

This is my personal reference on how to code in Python using Docker.

Python is one of my top programming languages. These days, one thing I avoid is to install many things on my computer just to try that piece of code or just an idea; this applies to the programming languages I use these days (Ruby, Go and C#). Once you install the tools, change your laptop and try to reproduce your environment; that’s one of the main issues for me (I see you .NET).

Then you find Docker. You need to try it to understand the power it can bring to your skills and how it can increase productivity and make you smile again. How easy is to drop a sandbox and repeat your environment again. There is a funny post by Nick Janetkis but with a serious message for developers having same problem I mentioned.

Install Docker: Go here for installations. During the day I work on an Windows 7 laptop, in which, by using VirtualBox I set up an Xubuntu VM where I play with Docker. Pretty nice for my purposes.

Ok, time for the notes. House keeping:

Let’s check if docker is running. Run in terminal or git-bash the following command:

docker version

Note: if by some reason, you see an error as follows:

$ docker version
Client:
Version:      1.12.6
API version:  1.24
Go version:   go1.6.4
Git commit:   78d1802
Built:        Wed Jan 11 00:23:16 2017
OS/Arch:      windows/amd64
An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/version: open //./pipe/docker_engine: The system cannot find the file specified.

Then check this post.

Run the docker hello world example:
docker run hello-world
Previous line:

  1. Will check if hello-world image is cached in computer (otherwise it will download image from hub.docker.com)
  2. Then it will create a container
  3. Run the container.
  4. If you get a raw Hello from Docker message, you are good to continue.

My VM has python 3.5.2 (I need an installed version if I plan to code in my VM):
python3 --version

For compatibility reasons I want a Docker image with same version ():
docker pull python:3.5.2
Navigate to hub.docker.com to search for an image that suit your needs. In our case, I searched for python and from the list I choose the version for 3.5.2.

Verify your container’s python version:
docker run python:3.5.2 python --version
This docker’s command instructs to run against an image python with version 3.5.2 the code python --version. The expected result is a legend Python 3.5.2.

In a similar way, I can run others commands against the new container.
docker run python:3.5.2 ls

NOTE: keep in mind this keeps adding new containers to the list. Find this by running:
docker ps -a
Top entries belong to your previous “docker run..” executions.

 

Another nice way to run docker is by running in a throwaway container:

docker run --rm python:3.5.2 sh -c \ "python --version"

or

docker run --rm python:3.5.2 sh -c \ "python --version && exec python --version"

So:

  • --rm tell to Docker CLI to automatically issue a docker rm command once the container exists. That way, we don’t leave anything behind ourselves.
  • We chain the built step (python --version) and the execution steps (exec python --version) using the shell logical operator &&. So, in this line we run 2 commands on the shell inside the container.
  • We pass our commands to sh -c because if we were to simple docker run  python:3.5.2 "python --version", Docket would try to execute the program but it will fail. So instead, we start a shell and instruct the shell to execute the command sequence.

 

To create a dockerfile, at least should have something like following:
FROM python:3.5.2
COPY . /src
RUN ["python", "--version"]

This Dockerfile instructs to use docker image python:3.5.2, then copy the content of the folder’s current content (if any content) into a “src” folder inside the image, finally run bash command python with parameter –version.

Finally, docker development tends to create a new image from solution we are creating. To do this:
docker build -t gpalazuelos/mydemo .
This docker command instructs to build a new image, with tag (name) gpalazuelos/mydemo, takes the code in current folder (.). To this action, some people refers to it as containerize an application.

This creates the container, executes the code and finalize the container. If you run command
docker ps -a
you won’t find this container.

WordPress… plugins… they can fail… BOOM!

Let’s say that your super WordPress site has been running without issues. Suddenly, it happened to me: one of them was not working, and worst, it didn’t allow me to access my WP-admin site. Boom!

Due to the nature of plugins, I will check this entry in the future, I’m sure. So, here is the fix.

To fix it, search in the WP database, in table options, for an entry called ‘active_plugins’.

Once you got it, update values
a:1
to
a:0

If you have more than one, you will likely to reduce the number by one.

After this action, it deactivated all my site plugins. Not big deal as there were quickly activated.

I hopes this helps in you case you are in emergency, as I was. Cheers.

SQL Server database – add database diagrams error

One of the nice features you had back in SQL Server 2000 was the ability to create ER diagrams directly in the database tool. I really enjoyed this feature cause you had the ability to start directly creating tables, fields structure and links between tables immediately.

While being busy working with Oracle and pre-installed databases in MSSQL, I didn’t note that if you want to use this feature in SQL Server 2012 Management Studio, you must execute an special configuration directly into the database.

So, if you create your database using the default options, like I did, and try to create a new diagram, you get an error as follows:

Database diagram support objects cannot be installed because this database does not have a valid owner.  To continue, first use the Files page of the Database Properties dialog box or the ALTER AUTHORIZATION statement to set the database owner to a valid login, then add the database diagram support objects.

When using default options, database is not getting an owner. Then, you must run the following T-SQL query to enable the required functionality (assume database name is DB_demo and you set user SomeUser as owner):

ALTER AUTHORIZATION ON DATABASE::[DB_demo] TO SomeUser
GO

By doing this, now you have the option to create ER diagrams in SQL Server Management Studio.

Have a good day.

© 2017 Gerardo Palazuelos

Theme by Anders NorénUp ↑