2015-09-21

Useful links

A collection of useful links. Mostly for my own memory but might also be useful to others. Updated 2015-09-21

Atari related:
https://makezine.com/2015/01/08/atari-emulator-uses-raspberry-pi-to-play-800-games-and-more/ (added 2015-09-21, checked 2015-09-21)

Apple related: 
http://davespicks.com/writing/programming/mackeys.html (added 2015-09-21, checked 2015-09-21)

2014-12-27

SSH portforwarding with autossh

Things you don't do daily you tend to forget. I a couple of Linux servers at home, and usually they just keep chugging along minding  their own business, but now and then they need some love and care. I know I always tend to forget how to do stuff. I spend hours researching things, set them up, get them to work, only to forget most about it when I have to redo it or change something in the future. Therefore I've decided to collect my knowledge and configurations in a blog so I don't have to rack my foggy memory, chase down .history-files or dead links. And with some luck these posts are useful for someone else. This might not be the best way to do it, but it worked for me. 

How to do portforwarding with SSH and autossh under Debian.

Create dedicated user, ex. tunnelguy, on both source and destination. I use gid / uid 500 for special accounts. Make sure it's not taken.

On both source and destination (as root or sudo):
# groupadd  -g 500 tunnelguy
# adduser --firstuid 500 --gid 500 tunnelguy

You can use a "simple" password on the destination first for testing. When everything works you can set hard password or use passwd -l to lock the  account. You wont be using password authentication in the future.

On the source:
# su - tunnelguy
$ ssh-keygen

Set no password, save in default location:
$ cat .ssh/id_rsa.pub

Add the contents of .ssh/id_rsa.pub to .ssh/authorized_keys of tunnelguy on destination. Test it from the source:
# ssh -l tunnelguy -i /home/tunnelguy/.ssh/id_rsa


You will be asked to confirm the authenticity of the destination host. Just answer "yes".
Test the tunnel from the source:

# ssh -T -f -L 80:localhost:80 -N -l tunnelguy -i /home/tunnelguy/.ssh/id_rsa


The command should execute and return to the prompt without further notice. Check that ssh is running with ps aux. You should also be able to telnet to localhost at the specified port on source and arrive at the destination.  Kill the tunnel and set up autossh. should be enough to replace ssh with autossh:
# autossh -T -f -L 80:localhost:80 -N -l tunnelguy -i /home/tunnelguy/.ssh/id_rsa

To test that autossh works kill the sshd-process on the destination:

# netstat -tnp | grep sshd
tcp        0     36 :22      :65108    ESTABLISHED 6914/sshd:  some-user
tcp        0      0 :22      :37675    ESTABLISHED 12019/sshd: tunnelgu


"our" process-ID is 12019, kill it!

# kill 12019

wait a little to let autossh notice that the tunnel is down and reconnect it

# netstat -tnp | grep sshd
tcp        0     36 :22      :65108    ESTABLISHED 6914/sshd:  some-user
tcp        0      0 :22      :37676    ESTABLISHED 12022/sshd: tunnelgu


Tada! You can also check what's happened in /var/log/messages.

Add the autossh-command to  /etc/rc.local to have it automatically connect when the server boots.

2013-03-16

mdadm

Things you don't do daily you tend to forget. I have a Linux server at home - well, I have several, but that's another story - this particular one use software RAID, a simple mirroring RAID-1. I've been using it quite long now and it has always worked well. You wont get the prestanda of a hardware RAID ofcourse, but you get about the same safety level.

Now and then you will still run into problems somehow, a failing disk, software errors, configuration errors... I have had a mysterious error on this one which I think I just solved though. Every time I rebooted the server one of the RAID-partitions would fail, one of the disks was missing. This made me a bit hesitant to reboot it, once it would come up at all and I was afraid I had managed to destroy the RAID. Luckily it wasn't so and I managed to repair it and get it up and running without  loosing anything. Anyway, today, when checking  /etc/mdadm/mdadm.conf I noticed a typo, might have crept in when I upgraded the Debian-distro when they changed device names in /dev.

Anyway, I'm rambling a bit now. The real point of this post, and others I hope/might make, is to collect a bunch of handy commands, configurations etc. I know I always forget how to do stuff. I spend hours researching things, set them up, get them to work. Only to forget all about it so when I have to redo it or change something I forgot all, the links I had is dead, or I dont find the same source again.

So here will follow a more or less sorted hopefully growing list of handy commands, configurations, tricks  etc. regarding software RAID on Debian Linux that is or has been useful to me, but that might also be useful for others.

-+-+-+-+-+-+-

Lost drive from RAID-1, re-add failed drive /dev/sda8 to raid /dev/md3:

 mdadm --manage /dev/md3 -a /dev/sda8

Check status of RAID:
~> cat /proc/mdstat
Personalities : [raid1]
md3 : active raid1 sda8[2] sdb8[1]
      140817600 blocks [2/1] [_U]
      [======>..............]  recovery = 34.5% (48633344/140817600) finish=47.2min speed=32499K/sec

md4 : active raid1 sda9[0] sdb9[1]
      240832 blocks [2/2] [UU]

md0 : active raid1 sda1[0] sdb1[1]
      272960 blocks [2/2] [UU]

md1 : active raid1 sda5[0] sdb5[1]
      4883648 blocks [2/2] [UU]

md2 : active raid1 sda6[0] sdb6[1]
      9767424 blocks [2/2] [UU]

unused devices:


Showing status with one device rebuilding.

2013-02-21

Bygga ny dator

Det började med att jag skulle föra över en massa gamla videoband till datorn. Detta ledde till att jag fick dåligt med diskutrymme vilket ledde till att jag bytte ut en disk i datorn mot en 2TB, vilket i sin tur fick datorn att börja bete sig mysko. Varför vet jag inte riktigt, möjligen så ledde den ökade strömförbrukningen för den nya disken att nätagget inte orkade med och gav oren ström till datorn, eller så tajmade det sig inte bättre än att ett elakt virus smög sig in samtidigt. Det artar sig som att program krashar lite slumpvis ibland, och nu och då blåskärmar datorn på ett sätt som den inte gjorde innan jag bytte disk. 

 Strunt samma! Den är inne på sitt sjunde år så det är hög tid att byta ut den. Jag har tänk göra det i flera år men nu har jag äntligen kommit till skott. Delarna är beställda på ÅRB i stan, det enda som är kvar att göra är att välja ett bra chassi, skruva ihop härligheten och köra vidare. När jag höll på att kolla upp den nya datorn så hittade jag en sammanställning jag gjorde förra gången jag satte en dator själv, det var datorn innan den jag har nu. Det var för tio år sedan, och även om jag fick mycket dator för pengarna då, bl.a ASUS värstingkort 2003, P4PE, så får jag så otroligt mycket mer för pengarna idag....

nydator20030129.txt

Chassi: Miditower                               Storlek DxBxH, 5.25", 3.5", kortpl.
Datorbutiken:   Cold Ebony 300W (CASA06)        490x192x437, 4/0, 2/2, ?         495.00
Komplett.se:    Q-Tec Midi 300W (113040)        440x200x350, 3/0, 1/2, 7         395,00
                Q-Tec Midi sv. 350 W (113046)   430x190x430, 3/0, 2/1, 7         577,00
JME:            Som 113040 (15275)                                               595,00
Oneshop:        NN 350W (12962)(som 113046)     430x190x430,                     554,00
ClasOhlsson     32-4733                         200x360x480, 3/0, 2/2            595,00

Moderbord:                                      Inkommer
Datorbutiken:   Asus P4PE, ljud + lan           030215                          1585,00
Komplett:           "    "    "                 lager                           1441,00
JME:                "    "    "                 030129                          1495,00
Oneshop:            "    "    "                 030213                          1374,00

CPU:
Datorbutiken:   P4 Northwood 2.0GHz m fläkt.                                    1869,00
Komplett:       Ej fläkt?                                                       2120,00
JME:            m. fläkt                                                        2079,00
Oneshop:        m. fläkt                        030130                          1849,00

Cpufläkt:
Datorbutiken:
Komplett:       Cooler Master < 3,06 GHz (114671) 3800 rpm/ 35dB                 141,00
                Cooler Master < 2,4 GHZ (108743) 3800rpm / 34,5dB                141,00
                PAPST < 2.0 GHz (110480) 3900 rpm / 27dBa                        295,00
JME:
Oneshop:

Minne:
Datorbutiken:   Standard 256 Mb 400MHz          030130                           613,00
Komplett:       DDR-DIMM 256MB (112665)                                          615,00
                TwinMOS 256 (113517)                                             648,00
JME:            Samsung 333MHz                                                   669,00
Oneshop:        Mycket dyrare.

Hårddisk:
Datorbutiken:   IBM Deskstar 180GXP 120Gb 7200rpm 2Mb UDMA100 IDE               1601,00
                Maxtor DiamondMaxPlus9 6Y120L0 120Gb 7200rpm 2Mb UDMA133 IDE    1570,00
                Maxtor DiamondMaxPlus9 6Y120P0 120Gb 7200rpm SE 8Mb 133 Fluid   1746,00
                Seagate Barracuda V ST3120023A 120Gb 7200rpm 2Mb UDMA100 IDE    1568,00
                  "         "      8 MB                                         1959,00
                WD Caviar XL 120Gb 7200rpm SE 8Mb UDMA100 IDE                   1597,00
Komplett:       Maxtor IDE ATA-133 120GB 7200RPM.                               1723,00
                Seagate Barracuda V 120GB 7200RPM. 100 2MB ST3120023A           1688,00
                   "     "        8MB                                           1962,00
                WD 120 GB 2Mb                                                   1744,00
                          8MB                                                   1650,00
JME:            IBM Deskstar 180GXP - 120Gb IDE UDMA-100 7200 RPM Tyst!         1795,00
                Maxtor 120Gb                                                    1895,00
                Seagate 120GB                                                   1795,00
                WD 120GB                                                        1699,00
Oneshop:        IBM Deskstar 120GXP 120GB                                       1649,00
                IBM 120.0GB UDMA-100 3.5" DeskStar 180GXP, IC35L120AVV207       1499,00
                WD 120 GB 8 MB                                                  1625,00

CD/DVD
Datorbutiken:   Lite-ON  16X/48X                                                 514,00
Komplett:       Sony 16X/40X 512K cache                                          520,00
                LG 16X/48X                                                       520,00
JME:            LiteOn                                                           479,00
Oneshop:        Samsung 16/48                                                    499,00
                 " " utan mjuk                                                   425,00
ClasO.          DVD-ROM, Memorex. Läser DVD 16x och CD 48x. M DVD-program        675,00

Brännare:
Datorbutiken:   ASUS CRW-4816A 48x16x48x FlextraLink (Burn Proof) Retail         618,00
Komplett:       Asus IDE 40x/12x/48x - CRW-4012A, Intern Retail (FlextraLink)    577,00
JME:            40x16x48x Arrgo CD-RW Veritas Retail Superlink/Justlock          579,00
Oneshop:        Aopen CD-RW 48X/12X/50X ATAPI Internal Retail                    499,00

Grafik:
Datorbutiken:   Hightech Excalibur ATI Rage 128 Pro 32Mb SDRAM Retail AGP        342,00
                Sapphire ATI Radeon 7000 64Mb SDR TV-out Retail AGP              399,00
Komplett:       Sapphire Radeon 7000 32MB SDR.                                   391,00
                Gainward AGP GeForce2 MX-200 64MB                                523,00
JME:            Prophet 4000 Kyro 4000XT 64Mb AGP TVout                          495,00
Oneshop:        Microstar VGA-Card Geforce 4 MX440SE 64MB DDR AGP TV-Out         700,00

Mus:
Datorbutiken:   Microsoft Trekker Wheelmouse PS/2                                 83,00
Komplett:       Microsoft Trekker Wheelmouse PS/2 bulk                           115,00
JME:            Ej billig på möss
Oneshop:        bara lyxmöss

2012-08-10

Hello my blog...

...almost forgot you are here. How are you? Feel a bit lonely? Yeah, I know, shouldn't have forgot about you. But you know, there's so much else to do.. And everyone else blogs. And I barely read any other blogs. There are several I know I should read, but I just don't..

Well, I promise I'll get back to you, soon. And write something that might be.... something... good.. interresting.. Maybe.. We'll see....