Saturday, June 1, 2013

Utilities: Linux System Troubleshooting

Source: https://sites.google.com/site/al271828183x/techblog/utilitieslinuxsystemtroubleshooting




When you need to make some investigation or troubleshooting of your System running Linux OS, check the list below of useful utilities that can help you to make your live easier.

How-To setup SSH Server on Embedded Linux Targets


Source : https://sites.google.com/site/al271828183x/techblog/dropbearhow-tosetupsshserveronembeddedlinuxtargets


'm using SSH Server on Embedded Linux Targets for my development purposes. To be more specific I'm using Eclipse with Remote System Explorer extension, which requires SSH connection to be established between Development Station and Embedded Linux Target.
Below is a simple step-by-step guide to setup SSH Server (Dropbear) on your Embedded Linux Target.

  • You need to prepare "sftp-server" for Embedded Linux Target, so you need to cross-compile OpenSSH
    • Download and unzip OpenSSH source code (for example: openssh-6.0p1.tar.gz)
    • In OpenSSH directory create "build" sub-directory
    • In the "build" directory create following "build.sh" script (you need to modify path to your cross tools, gcc and strip):
      #!/bin/bash
      export PATH=/opt/crosstool/gcc-3.4.5-glibc-2.3.6/arm-cirrus-linux-gnu/bin:$PATH
      ../configure --prefix=$($PWD) CC=arm-linux-gcc --host=arm
      make sftp-server
      arm-linux-strip -v sftp-server

    • Run "build.sh" (don't forget "chmod a+x build.sh")
    • "sftp-server" executable will be created, copy it to your Embedded Linux Target and place it to the "/usr/libexec" directory
  • Now you need to create SSH key pair on your Development Station (I'm running on Fedora distribution)
  • In directory "~/.ssh" execute "ssh-keygen"
  • Copy "id_rsa.pub" file to Embedded Linux Target and place it to the "~/.ssh" directory
  • On Embedded Linux Target from directory "~/.ssh" execute following command:
cat id_rsa.pub >> authorized_keys
  • Dropbear, you need to cross-compile Dropbear for your Embedded Linux Target
    • Download and unzip Dropbear source code (for example: dropbear-2012.55.tar.gz)
    • In Dropbear directory create "build" sub-directory
    • In the "build" directory create following "build.sh" script (you need to modify path to your cross tools, gcc and strip):
#!/bin/bash
export PATH=/opt/crosstool/gcc-3.4.5-glibc-2.3.6/arm-cirrus-linux-gnu/bin:$PATH
../configure --prefix=$($PWD) CC=arm-linux-gcc --host=arm
make
arm-linux-strip -v dropbear
arm-linux-strip -v dropbearkey
  • "dropbear" and "dropbearkey" executables will be created, copy them to Embedded Linux Target and place them in "/bin" directory
  • Now you need to create SSH host keys for Dropbear
  • On Embedded Linux Target create directory "/etc/dropbear/"
  • In the "/etc/dropbear/" directory execute following lines:
dropbearkey -t dss -f dropbear_dss_host_key
dropbearkey -t rsa -f dropbear_rsa_host_key
  • Running SSH Server
  • On Embedded Linux Target execute following line:

dropbear -s -g