Posts

Showing posts from 2015

Fixing USB Drive

My old pendrive get corrupted. I've used it to install ArchLinux and needed it repartitioned back as regular pendrive. Unfortunately using "always working" HP USB Disk Storage Format Tool corrupted the drive on my Windows 8.1 box. It just seemed to remove partition table, but drive was not visible on Windows and Drive Manager was unable to format it. Here what I did to recover it (note diskpart was started from elevated command line): Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved. C:\WINDOWS\system32>diskpart Microsoft DiskPart version 6.3.9600 Copyright (C) 1999-2013 Microsoft Corporation. On computer: KARO-VAIO DISKPART> list disk   Disk ###  Status         Size     Free     Dyn  Gpt   --------  -------------  -------  -------  ---  ---   Disk 0    Online          465 GB      0 ...

Hurricane Electric's IPv6 on Raspberry Pi

First ensure that you have ipv6 module added to /etc/modules. If yes, you shall see IPv6 local address via ifconfig command: pi@raspberrypi ~ $ ifconfig eth0      Link encap:Ethernet  HWaddr **:**:**:**:!!:##           inet addr:192.168.111.11  Bcast:192.168.111.255  Mask:255.255.255.0           inet6 addr: fe80::1234:9999:3333:2222/64 Scope:Link           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1           RX packets:470 errors:0 dropped:0 overruns:0 frame:0           TX packets:234 errors:0 dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:1000           RX bytes:48774 (47.6 KiB)  TX bytes:31032 (30.3 KiB) lo        Link encap:Local Loopback           inet addr:127.0.0.1  Mask:255.0.0...

Dropbear SSH keys and autossh on OpenWRT

Image
I have a box on Amazon EC2. And I want to have my OpenWRT that is behind IPv4 CGN and have public IPv6 to be reachable from IPv4 Internet. The best idea is to use ssh reverse tunnel connected with autossh to keep connection going. The very first think is to test if I can connect to my Amazon instance from my OpenWRT: root@OpenWrt:~# ssh 54.111.111.111 Host '54.111.111.111' is not in the trusted hosts file. (ssh-rsa fingerprint md5 0f:51:11:11:11:11:11:11:11:11:11:11:11:11:11:11) Do you want to continue connecting? (y/n) y root@54.111.111.111's password: At this point the public key of remote host will be added to .ssh/known_hosts. It is important as we can't have autossh to interact with console in future. root@OpenWrt:~# cat .ssh/known_hosts 2001:1111:1111:1111::1111:1111 ssh-rsa AAAAB3N....... 54.111.111.111 ssh-rsa AAAAB3N.......... Now we need to generate public/private key pair we will be using to connect to our Amazon instance. Invoke fol...

Hardening OpenWRT - adding non-root user account

I have at home an OpenWRT on TP-Link 1043ND. As I'm most of the time out of my home, I use this for two functions:  - as reliable WiFi Access Point  - as last resort remote access device  - as a box used to wake up other Ethernet enabled devices @ home. As this box is exposed to Internet via IPv6 address, I decided to harden it a little. 1. Adding extra non privileged user account: root@OpenWrt:~# opkg update root@OpenWrt:~# opkg install shadow-useradd root@OpenWrt:~# mkdir /home root@OpenWrt:~# useradd -D GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL= SKEL=/etc/skel CREATE_MAIL_SPOOL=no root@OpenWrt:~# useradd -m -s /bin/ash bart root@OpenWrt:~# cat /etc/passwd root:x:0:0:root:/root:/bin/ash daemon:*:1:1:daemon:/var:/bin/false ftp:*:55:55:ftp:/home/ftp:/bin/false network:*:101:101:network:/var:/bin/false nobody:*:65534:65534:nobody:/var:/bin/false bart:x:1000:1000::/home/bart:/bin/ash root@OpenWrt:~# passwd bart Changing password for ...

Getting access to home network using IPv6 and SSH tunelling from IPv4 Internet

My new ISP is providing me with CGN (carrier grade NAT) for IPv4 but also full /64 IPv6 connectivity with routable unicast addresses. So I've enabled IPv6 on my Raspberry Pi. I've also bougth for couple of bucks a cheap VPS ( http://www.lowendtalk.com/ ) that have dual stack to be used as proxy for access to my home network. The access I will configure using SSH tunnels, what allows me for opening access only when I really need it. After logging to my VPS I issue the following to facilitate local post forwarding from VPS to my home network: ssh -L 10.111.111.111:8080 : 192.168.1.1:80 -l pi 2a01:2222:2222:2222:3333:3333:3333:3333 The parameters are as follow: 10.111.111.111 is address of my VPS (man in the middle box). VPS will listen on port 8080 for incoming connections. 192.168.1.1 is an IP address of device I want to access on my internal home network. 80 is a port I want to access on the device in my internal home network. pi is user name that I want to use to ...

RPi pinouts

Image
I've been looking for pinouts of my RPi to wire it to some devices... And I believe the best resource is:  http://pi4j.com/

Nailing coffin of Application Server - 2PC / XA transactions with Spring Boot

Note: that article refers to Spring Boot 1.1.x, the XA support was embedded in Spring Boot 1.2.x, what I will cover another time. Recently I had to write an app that synchronizes queues with databases. Pretty dumb application that is far too simple to use any overkill technology. However, for full piece of mind I needed XA transactions between JMS queues and database. Here is how to enable XA for Spring Boot. 1. Transaction manager. You need transaction manager. I've chosen the Bitronix JTA Transaction Manager . Open source and free. The role of transaction manager is to track the state of distributed transaction on bulletproof way. Note that for it uses synchronized log files that are keep locally (here I've put them under 'run' directory). In your Gradle build script you need the following dependency: compile("org.codehaus.btm:btm:2.1.4") 2. Enabling transactions support and configuring JTA ransaction manager. It can be easily one by adding @Configu...

Get your machine information under windows

Recently I needed my Dell service tag to look up for some drivers. As it was connected to docking station, it turned out to typing the following in command prompt: C:\Users\bart> wmic csproduct Caption                  Description Computer System Product  Computer System Product IdentifyingNumber  Name            SKUNumber FGB4XW1            Latitude E6530               UUID                                  Vendor     Version 4C4C4544-0047-4210-8034-C6C04F585731  Dell Inc.  01