30 April 2012

126. linux ssh examples: rsync across portforwarded ssh and helping remotely via ssh behind firewalls

Even bog-standard ssh is pretty neat, since there's little that can't be done in the terminal. However, firewalls can be annoying and if you set somebody up with linux you will have to be prepared to support them for years to come -- at least with debian wheezy the odd breakage happen, and people tend to be less forgiving with linux problems than with windows problems.

Anyway.

1. rsync across a server 
A can connect to B, B can connect to C. A can't connect directly to C. B and C can't connect directly to A. B and C can connect to each other either direction. An example is when B is your home router and C sits on your local network, while A has a public IP but sits behind a corporate firewall.

You want to rsync from A to C

On A, do
ssh user_at_B@B_ip_address -L 5555:C_ip_address:22
then in another terminal
rsync -avz  --progress --stats -e "ssh -p 5555" /home/user_a/work user_c@localhost:/home/user_c/Documents

2. Helping someone in the terminal across a server
A and C can't connect to each-other. A and C can both connect to B. B can't connect to A or C. A wants to connect to C to start e.g a screen session to help out. An example is when both users A and C can connect to a lab router from their respective home, but their ISPs are preventing direct ssh access between them.

Setting up reverse ssh, on C, do
autossh -R 19998:localhost:22 user_B@B_ip_address

Connecting from A to C, do
ssh user_B@B_ip_address -L 19999:localhost:19998
then in another terminal
ssh user_C@localhost -p 19999

You can then set up a screen session to both help and teach.
http://verahill.blogspot.com.au/2012/02/debian-testing-wheezy-64-attach-to.html
http://verahill.blogspot.com.au/2012/03/fun-with-gnu-screen-setting-up-screenrc.html

28 April 2012

125. Fixed: No internet on old Dell after debian testing upgrade

The situation:
I remotely dist-upgraded someone's old Dell laptop (Inspiron 6000). They were running Wheezy, but had not done a full apt-get upgrade/dist-upgrade since January. After a reboot, the laptop would not connect to the internet via either the wired or wireless interfaces.

ip addr and ifconfig showed three ifs:
lo
eth0
eth1

NOTE: A simple reason why you don't have wireless is because you'll need firmware-iwlwifi -- make sure you've enabled non-free and contrib in your repos.

The solution:
Adding
auto eth0
iface eth0 inet dhcp

to /etc/network/interfaces and commenting out
allow-hotplug eth0

followed by executing
sudo service networking restart && sudo service network-manager restart

brought up the wired interface, allowing for installation of packages and remote help. These instructions are simple enough for most to follow and can get you back in the driver's seat.

Next, I installed the wicd packages (wicd-curses, wicd-cli etc.)
sudo apt-get install wicd-cli wicd-curses wicd-daemon python-wicd

 -- at this point about 70 other packages got pulled in. Suspicious. I had seen that apt wanted me to autoremove a lengthy list of programs:

The following packages were automatically installed and are no longer required:  python-crypto mono-2.0-gac python-tagpy libgnomekbd4 seahorse-daemon libboost-python1.46.1 python-pyasn1 libswscale0 libjs-jquery-ui python-twisted-core ekiga python-opengl rpm2cpio xsltproc pnm2ppa libavutil50 gnuchess-book  gnome-nettool gnome-games-extra-data gnome-desktop-data libgnomepanel2.24-cil aisleriot gtali libglade2.0-cil libsushi-1.0-0 python-mako glchess libbabl-0.0-0 gir1.2-javascriptcoregtk-3.0 libgegl-0.0-0 ttf-sil-gentium libicu44  libraw2 libx264-116 libx264-118 tcptraceroute gir1.2-sushi-1.0 gnome-video-effects libcamel-1.2-23 python-clientform gnome-games gnome-session-canberra gdebi anthy-common anthy quadrapassel python-twisted-web libedataserverui1.2-11  update-manager-core gnobots2 libgnome-media0 libqtmultimediakit1 gnome-cards-data liferea-data libgraphite3 libmagickcore4-extra libglew1.6 rhythmbox bsh-gcj python-gdata gedit libnm-util1 xdg-user-dirs-gtk libgexiv2-0  python-gtksourceview2 gnome-office update-manager-gnome libwebkit-1.0-2 python-gtkglext1 xulrunner-5.0 libart2.0-cil libboost-program-options1.46.1 libminiupnpc5 libcamel1.2-19 librpmio2 update-notifier-common libpostproc51 librpm2  seahorse rpm-common libgnome2-perl libaccess-bridge-java-jni xulrunner-8.0 xulrunner-9.0 libnotify1 libaccess-bridge-java update-notifier python-mechanize libwebp0 libgnome2.24-cil libndesk-dbus1.0-cil gnome-media-common libgpod4  gnibbles libavformat52 rhythmbox-data libmono-cairo2.0-cil gedit-plugins libgrilo-0.1-0 zeitgeist-core system-tools-backends libboost-thread1.46.1 libgweather1 libgnome-bluetooth7 dasher python-configobj guile-1.8-libs shotwell  libpolkit-gtk-1-0 libdmapsharing-3.0-2 python-serial gedit-common libboost-serialization1.46.1 libboost-date-time1.46.1 libgmime2.4-cil python-gnomedesktop software-center libopal3.6.8 python-pam python-openssl libhwloc3  libmono-i18n-west2.0-cil libgssdp-1.0-2 simple-scan gir1.2-webkit-3.0 libebook1.2-10 libqtlocation1 python-markupsafe libgck0 python-webkit libmono-posix2.0-cil bsh libedataserverui-3.0-0 rhythmbox-plugin-cdrecorder libgdata11  libhunspell-1.2-0 librhythmbox-core4 librhythmbox-core5 libgtksourceview2.0-common libmono-security2.0-cil libgtksourceview2.0-0 libgnome2-vfs-perl gnotski dasher-data libegroupwise1.2-13 libvpx0 libedata-cal-1.2-11 libnm-glib2  gnome-doc-utils libecal1.2-8 python-twisted-conch libgmime-2.4-2 python-louie libunique-1.0-0 libedataserver1.2-14 libpython2.6 libimobiledevice1 libedata-book-1.2-9 python-nevow gnome-games-data iagno glines media-player-info  python-pysqlite2 libcupsdriver1 python-gnomeapplet libclutter-gtk-0.10-0 gnome-sudoku libslab0a libmagickcore4 tcl gir1.2-gucharmap-2.90 libmono-sharpzip2.84-cil libmagick++4 libmono-corlib2.0-cil python-epsilon  libgnome-window-settings1 libgpod-common rhythmbox-plugins libv8-3.5.10.24 libv8-3.6.6.14 libcryptui0a ntfsprogs python-axiom libmozjs2d libquvi0 python-bugbuddy libmozjs5d gir1.2-rb-3.0 libtracker-client-0.10-0 liferea libpt2.6.7  libmozjs8d libmozjs9d python-coherence libmagickwand4 libchamplain-0.8-1 libgupnp-1.0-3 python-gdbm libchamplain-gtk-0.8-1 gnotravex gnome-netstatus-applet libnl1 libnl3 gnect libavcodec52 python-evolution libanthy0 libyajl1  liboobs-1-4 libgucharmap7 liboobs-1-5 mahjongg libndesk-dbus-glib1.0-cil libid3tag0 libraptor1 gnome-system-tools python-wnck libtracker-sparql-0.10-0 libgnome-desktop-2-17 libtracker-sparql-0.12-0 hamster-applet gnuchess libfreerdp0  libgnome-vfs2.0-cil min12xxw libwebkit-1.0-common minissdpd transmission-common libgtkglext1 libnatpmp1 libnet1 python-twisted-bin libmatroska4 libgupnp-igd-1.0-3 libmono-system2.0-cil libgnome2-canvas-perl file-roller  libxalan2-java-gcj transmission-gtk python-rdflib sound-juicer gnomine

 and suddenly it made sense:

aptitude search gnome-core

pB  gnome-core                                                                                                     - The GNOME Desktop Environment -- essential components


Basically, it seems that gnome got 'uninstalled' (technically just the meta package) -- most of the files related to it won't get removed until you do apt-get autoremove, but it's crippled enough to reduce functionality.
At least that was my thesis.

sudo service network-manager stop
sudo wicd-curses eth1

showed no wireless networks. Something not right.

Make sure the system is really up to date, then reboot, and have another go at it:
sudo apt-get update && sudo apt-get upgrade
which pulled in some glib-networking-* packages.
sudo apt-get install gnome gnome-core
sudo shutdown -r now

After boot
sudo service network-manager stop
sudo wicd-curses eth1

et voilá -- I do get a list over the local wireless networks. There's still a worrying list over stuff when you look at what would be autoremoved (e.g. apt-get -s autoremove)

Rebooted and the wireless interface seems to be handled ok by network-manager.
There is still a number of packages marked for autoremove, so...
sudo apt-get autoremove

System seems to work ok still.
sudo apt-get install update-manager-gnome update-notifier


And my job is done.

Here's the final /etc/network/interfaces:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth1
#NetworkManager#iface eth0 inet dhcp
#allow-hotplug eth1
auto eth1
#iface eth1 inet dhcp
auto eth0
iface eth0 inet dhcp


23 April 2012

124. gnome-activity-journal and zeitgeist

It may not be advertised widely, but zeitgeist + journal might help save your behind when you're in a hurry and can't find a file.

aptitude show zeitgeist
" Zeitgeist is a service which logs the user's activities and events (files opened, websites visited, conversations held with other people, etc.) and makes the relevant information available to other applications."

And that it does. A service without an interface isn't terribly useful -- so you will want to install gnome-activity-journal as well.


Chances are that zeitgeist is already running on your system, so that you only need to install gnome-activity-journal, which is present in the repos, and then you'll get access to all the old data you've been accumulating.