Friday, 11 September 2015

Make fabric using port other than standard ssh port

For deploying source code to production or UAT server , the fastest way is using fabric which we can automate, as we are developer are lazy :).

Fabric can run all the same command you do to a server or a lot of server automaticaly, no typo and more workflow type of update. Don't do it manualy by typing ssh login and run command. what if you update to 100 production server ? are you still a diligent developer ?

Fabric come for the help and i use it for many of repetitive task which i can automate. But problem is arise when i cannot access the production server directly. This because the security team !!! why they make it even harder ?

So they need you upload your code only from a single master SSH server, called cleanroom, which have connection to all the production server. So the security team will got the logs only from the cleanroom. so smart but not so good news for developer like me.

But you remember, port forwarding in SSH ? this come to the rescue, handy command line tools. Even you can only connect to the "Cleanroom", you can connect as you are go directly to the production machine.

So here are my setup i would like to share with you. sst...don't let the security guy now about your smart idea !!!

So let say the environment like this :

1. local dev machine , your pc : 192.168.1.10
2. Cleanroom machine , ip : 192.168.200.10
3. Production machine , ip : 192.168.111.10

you can only SSH to the cleanroom machine. and you only need SSH to your production machine to deploy your code.

step 1 :
Make a connection to your cleanroom and port forward to your dev machine.

smartdev@bsdstack$: ssh -L 8080:imsmart@192.168.111.10:22 securenow@192.168.200.10


So this will create a local port at 8080 listening and will forward it to production machine port 22 via cleanroom machine.

step 2 :
smartdev@bsdstack$: fab -H 127.0.0.1:8080 update_code


second step will run the fabric command, go to localhost port 8080 which will be connect to your production machine.

you can try also using ssh to your production machine

smartdev@bsdstack$ ssh 127.0.0.1 -p 8080


this will open ssh connection to your production machine.

Now i can do my fabric command center again, i am rocks !!!

Well, hope this help anyone looking for a solution.


0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More