SSH Tips and Tricks

Part 1 – Screen

Screen is a program that can create virtual terminals inside your current session. If you are used to a tabbed web browser you can think about it as adding tabs to your terminal. And if your server allows it can allow you to disconnect sessions and keep then running in the background, even if you log out.

You can install screen on debian with apt-get by running “sudo apt-get install screen” and “yum install screen” for rpm based systems.

Start screen by running:

$ screen

The first time you run screen it will create a new window. this window is just like the session you left behind to enter screen. you can tun any program you usually would have. and exit or close the window by typing exit and pressing enter.

Now got the fun part! Enter a new screen session by running screen. You can now run any program you like and leave it running, start your cli mail client or wget a large file. Now press Ctrl-a and then c. This will create a new windows (or tab if you will) in your current screen session. Ctrl-a is the screen hotkey to allow the user to enter a command to screen and not the currently running program or the current shell. In the previous example Ctrl-a c we told screen we where going to give it a command and then gave it the C command which stands for Create, as you can guess this created a new screen window.

Some of the important screen commands are Ctrl-a k: kills the current window, same as typing exit. Ctrl-a w: lists all open windows, Ctrl-a n: go to the next window or cycles through the available windows. Ctrl-a d: this will detach the current sessions, this allows the sessions to run in the background while you are droppecked back into your shell. You can resume the session anytime later (even after logging out) by running:

screen -r <name of session>

You can view a list of the available screen sessions by running:

screen -ls

However there is a wildcard resume that will resume the last open session or create one if there are none, to resume any open session run:

screen -R

Screen can also do much more, If you want to learn more take a look at the screen manual.

Part 2 – Sceen as a proxy

Openshh server has the ability to be used as a SOCKS proxy. Using it as a socks proxy will allow you to run your proxyed applications network traffic through the ssh server.

Windows with putty

You can use putty to allow a windows client to connect to the ssh/socks proxy. On the putty client go to the Tunnels page and enter any source port you want, this will be the port that you will tell your local application to use at the proxy server port. Leave the destionation field blank and select the dynamic checkbox. Select Add to add the port. It should look like this:

Putty configured for socks proxy

From here once you connect to the ssh server the port you specified on 127.0.0.1 or localhost will open as a socks proxy.

Linux

To connect to an ssh server and use it as a SOCKS proxy using linux connect to the ssh server the way you normally would but add -D <port> as a paramater. -D tells the destionation port to be dynamic and <port> is the port that will listen for the proxy server on the local computer, just remember if you are not root locally your port needs to be over 1024. Here is an example:

ssh -D 1234 mrlanrat@sshserver.com

Using the Proxy

Here is an example setting up the proxy with Firefox, it should be a similar configuration for other programs.Firefox configuration for socks proxy.

Part 3 – X11 Forwarding

X11 forwarding allows you to run X or graphical applications on the server over ssh. To forward X programs over ssh on Linux apply the -X paramater, below is an example.

ssh -X user@host

If you want to compress the X information while it is being transferd apply the -c argument.

ssh -c -X user@host

If And you can start X11 applications and allow the shell to still remain active by applying a ‘&’ to the end of the application. example:

firefox &amp;

If you want to start the complete X desktop over ssh and not just a single application you can run:

srartx

On windows you can enable ssh in putty by clicking the enable X11 forwarding checkbox in the X11 tab. screenshot below:

Putty with x11 forwarding

Part 4 – Reverse SSH

You can ssh into a server that is behind a NAT through a reverse ssh server. Put simply the server would need to ssh into either the client machine or a machine that the client has access to, like a middleman. When the server sshes into the other computer you will need to have it tunnel its port 22 (or the port that ssh is running on) to any port on the computer client or midleman that the server is sshing to. Below is an example of this:

ssh -R 2222:localhost:22 user@client

This assumes that port 2222 is the port the client or middleman will have open that will allow the client to ssh into the server. user@client is the user and host of the client or middleman server. From there have the client either ssh into itself or the middleman server and it will be tunneled into the server.


Car Aux Mod

Here is How I added a AUX inputs to my Delco Radio/CD player and a nice mount for my N810.

Part 1 – Adding The AUX Input

First off This worked on my Delco radio. It may work on yours, it may not. On My radio there is a nice AUX button right under the CD button. This goes to a AUX connector on the back of the unit. This is Delco AUX plug. It was meant to to to a separate tape deck. Unfortunately this plug needs an intelligent device connected to it to enable itself. If you are interested the pinout is Here. There is also a device you can buy that will plug into this AUX port and give you a normal RCA connection, but the idea of this is to spend as little money as possible and have the fun of doing it yourself

Warning: If you disconnect your radio from your car battery or any other source of power it may lock itself, this is part of the anti-theft feature. If your radio locks itself there is a link at the bottom with unlocking instructions.

The idea is to splice into the CD’s input with your own input. Here is the connector and the pins you will need. The ground is in between the Left and Right, but you can use any ground.

 

Here is my dash before the mod

 

Opening the Radio

 

Splicing the needed wires

I wired my 3.5mm AUX jack in the front of the unit. It barely fit. It would have been a lot easer to run the wires out of the unit and mount it elsewhere in your car. Anyway the idea is when you are on the CD input it will use the audio from the CD player unless there is a jack in the AUX input. I used a Radio Shack part # 274-0246 similar jacks will work but they may not allow you to switch from CD to AUX. Here is the wiring diagram of the jack.

Pin 1 - Ground - connect to radio ground
Pin 2 - Left Channel - wire from CD connector on main circuit board
Pin 3 - Left Channel - wire coming from CD player module
Pin 4 - Right Channel - wire coming from CD player module
Pin 5 - Right Channel - wire from CD connector on main circuit board

 

Here is the jack wired through the front panel

 

Testing it with my N810 before I put it all together

 

Putting it all back together

 

Part 2 – N810 Mount

I did not want spend the money to buy the rest of the mount that the N810 came with, or make anything that was too permanent. So I took the N810 half of the mount (the part the N810 came with) and decided to mount it in the empty slot in my dash. To do that I just screwed the end of it into a 3.5 inch long 2×4, and painted black to match. Here is the completed mount on its own, and in my dash.

 

Part 3 – Finished!

Here is the final product with the N810 all hooked up

Update: I also got a N810 cat charger to keep it going, playing lots of audio can drain the battery, and with canola I can keep the screen lit so I can always see what is playing.

Update 2: When using the AUX in you need to turn the volume up really high, that means that when you unplug it it will be extra loud, and hurt your speakers. in addition since the wires are so close together some of the CD player’s sound signal will get mixed in with your AUX input due to electromagnetic radiation. To fix that I made an audio CD with 80 minutes of silence. I used Audacity to create one long audio file, then burned it to a CD. It fixed this problem. I will upload a compresses ISO if this disk soon.

To see more and higher resolution photos go to the picasa gallery

Related Links

Where I got the mod idea and information from
Directions to unlock your radio
More assorted pinouts


Conky

Conky is a system monitor for linux. It can tell you almost anyhting your computer, sutch as CPU useage, memory useage, network infomration, and almost anything else. Here is what my Conky configuration looks like on my desktop.

 

To install Conky on a RPM based distribution run

# yum install conky

Or on a Debain based distribution run

$ sudo apt-get install conky

To get yours to look like that you need to put a file named .conkyrc in your home folder. Your home folder is usually /home/<username>.

This conky setup is very dynamic. It will display 1-4 possessors or cores, display the main root file system, up to 5 removable drives, and it will show all of the active network interface (wireless, wired, and wireless broadband) If you use a different network configuration for example two wired connections you can remove one of the unused ones and replace it with ypurs, or just add another entry.

My .conkyrc file looks like this

# Conky configuration

# Set to yes if you want Conky to be forked in the background
background no

# Font size?
font Sans:size=8

# Use Xft?
use_xft yes

# Text alpha when using Xft
xftalpha 0.9

# Update interval in seconds
update_interval 1.0

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

# Text alignment, other possible values are commented
#alignment top_left
#alignment top_right
#alignment bottom_left
alignment bottom_right
#alignment none

# Create own window instead of using desktop (required in nautilus)
own_window yes

# If own_window is yes, you may use type normal, desktop or override
own_window_type normal

# Use pseudo transparency with own_window?
own_window_transparent yes

# If own_window_transparent is set to no, you can set the background colour here
own_window_colour black

# If own_window is yes, these w# Text alignment, other possible values are commented
#alignment top_left
#alignment top_right
#alignment bottom_left
alignment bottom_right
#alignment none

# If own_window is yes, these window manager hints may be used
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# Minimum size of text area
minimum_size 200 5

# Draw shades?
draw_shades yes

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no

# Draw borders around graphs
draw_graph_borders yes

# Default colors and also border colors
default_color white
default_shade_color black
default_outline_color black

# Text alignment, other possible values are commented
#alignment top_left
alignment top_right
#alignment bottom_left
#alignment bottom_right
#alignment none

# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 12
gap_y 35

# Subtract file system buffers from used memory?
no_buffers no

# set to yes if you want all text to be in uppercase
uppercase no

# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 1

# number of net samples to average
# set to 1 to disable averaging
net_avg_samples 1

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale no

TEXT
${color white}SYSTEM: $nodename $machine ${hr 1}${color}
Uptime: $alignr$uptime
CPU: ${alignr}${freq_dyn} MHz
Processes: ${alignr}$processes ($running_processes running)
Load: ${alignr}$loadavg

${if_existing /sys/devices/system/cpu/cpu0}CPU1 ${alignr}${cpu cpu1}%
${cpubar cpu1 4}${endif}${if_existing /sys/devices/system/cpu/cpu1}
CPU2 ${alignr}${cpu cpu2}%
${cpubar cpu2 4}${endif}${if_existing /sys/devices/system/cpu/cpu2}
CPU3 ${alignr}${cpu cpu3}%
${cpubar cpu3 4}${endif}${if_existing /sys/devices/system/cpu/cpu3}
CPU4 ${alignr}${cpu cpu4}%
${cpubar cpu4 4}${endif}
${cpugraph 20}

Ram ${alignr}$mem / $memmax ($memperc%)
${membar 4}
Swap ${alignr}$swap / $swapmax ($swapperc%)
${swapbar 4}

Highest CPU $alignr CPU% MEM%
${top name 1}$alignr${top cpu 1}${top mem 1}
${top name 2}$alignr${top cpu 2}${top mem 2}
${top name 3}$alignr${top cpu 3}${top mem 3}

Highest MEM $alignr CPU% MEM%
${top_mem name 1}$alignr${top_mem cpu 1}${top_mem mem 1}
${top_mem name 2}$alignr${top_mem cpu 2}${top_mem mem 2}
${top_mem name 3}$alignr${top_mem cpu 3}${top_mem mem 3}

${color white}FILESYSTEMS ${hr 1}${color}
Root ${alignr}${fs_free /} / ${fs_size /}
${fs_bar 4 /}${if_mounted /media/disk}
Disk1 ${alignr}${fs_free /media/disk} / ${fs_size /media/disk}
${fs_bar 4 /media/disk}${endif}${if_mounted /media/disk-1}
Disk2 ${alignr}${fs_free /media/disk-1} / ${fs_size /media/disk-1}
${fs_bar 4 /media/disk-1}${endif}${if_mounted /media/disk-2}
Disk3 ${alignr}${fs_free /media/disk-2} / ${fs_size /media/disk-2}
${fs_bar 4 /media/disk-2}${endif}${if_mounted /media/disk-3}
Disk4 ${alignr}${fs_free /media/disk-3} / ${fs_size /media/disk-3}
${fs_bar 4 /media/disk-3}${endif}${if_mounted /media/disk-4}
Disk5 ${alignr}${fs_free /media/disk-4} / ${fs_size /media/disk-4}
${fs_bar 4 /media/disk-4}${endif}

${color white}NETWORK ${hr 1}${color}
${if_existing /sys/class/net/eth0/operstate up}IP (eth0):$alignr${addr eth0}
Down: ${downspeed eth0} k/s ${alignr}Up: ${upspeed eth0} k/s
${downspeedgraph eth0 20,90} ${alignr}${upspeedgraph eth0 20,90}
Total: ${totaldown eth0} ${alignr}Total: ${totalup eth0}

${endif}${if_existing /sys/class/net/wlan0/operstate up}IP (wlan0):$alignr${addr wlan0}
AP: ${wireless_essid wlan0} ${alignr}Bitrate: ${wireless_bitrate wlan0}
Down: ${downspeed wlan0} k/s ${alignr}Up: ${upspeed wlan0} k/s
${downspeedgraph wlan0 20,90} ${alignr}${upspeedgraph wlan0 20,90}
Total: ${totaldown wlan0} ${alignr}Tota: ${totalup wlan0}

${endif}${if_existing /sys/class/net/ppp0/operstate}IP (ppp0):$alignr${addr ppp0}
Down: ${downspeed ppp0} k/s ${alignr}Up: ${upspeed ppp0} k/s
${downspeedgraph ppp0 20,90} ${alignr}${upspeedgraph ppp0 20,90}
Total: ${totaldown ppp0} ${alignr}Total: ${totalup ppp0}${endif}

The Conky homepage


Extract, Compile, and Install Anything in Linux

From time to time every Linux user will run across a program that does not come in a nice packaged DEB or RPM. Often in the form of a tar.gz, tgz, tar.bz, tar, gz, tar.bz2 or tbz2 format. This is how you can make use of them. Remember to have a compiler installed and any dependencies for the software you installing.

Extract

To uncompress your file run the following command that applies to your extension.

$ tar -zxvf file.tar.gz
$ tar -zxvf file.tgz
$ tar -jxvf file.tar.bz
$ tar -xvf file.tar
$ gunzip file.gz
$ tar jxf file.tar.bz2
$ tar jxf file.tbz2

Compile

Often software will come with a readme or install file that should give you instructions on how to install it and any required dependencies as well as how use it. It will probaly say the same I have here, or something similar. Once you extract the source, cd into the newly created directory.

$ ls
$ cd path-to-software/

Now as root configure the software, this sets up the software and compiler for your system.

# ./configure
# make

Install

Okay, now for the last and simplest step, the install.

# make install

Everything should have gone well; enjoy your new software!


Pidgin Smilies

I use pidgin as my main IM client, but I have always felt that it has a lack of smilies, so here is my own custom smilies theme. It contains 120 smilies. I have also made a lite version that only contains 90. I got the smilies from a phpbb smilie theme, because they went well with the default smilie theme.

Mass Pidgin Smilies

Mass Pidgin Smilies Lite

Download Mass Pidgin Smilies Here

Download Mass Pidgin Smilies Lite Here


N810 USB OTG Adapter

The Nokia N810 has an OTG or On-The-Go USB controller, it allows for the device to function is both client and host mode. By default it is is client mode so when you plug it into your computer it acts as a USB storage device. It can be put into host mode by feature running a program on the tablet that will put it into host mode or use the OTG trigger. The USB plug on the tablet has 5 pins rather than just the standers 4 USB uses. If the extra pin is grounded it will put the N810 into host mode.

The same is true for the N800, but the N800 uses a Mini USB connector. The N810 uses Micro USB

    This is what I used to make my adapter

  • USB Extension Cable (any cable with a female USB type A connector will work)
  • Micro USB cable with male connector
  • Solder
  • Shrink tubing/Electrical Tape

Cut the two cables and separate the wires

This it is as simple as connecting the same color wires together, red to red, black to black, green to green, white to white, and finally the shield. I put each individual wire in shrink tubing and then the two wires in a larger piece of shrink tubing. I tried to ground the fifth pin to have it be a true OTG cable, but my soldering iron is too big and the connector is too small. (see the out of focus picture below). If anyone has any suggestions please let me know in the comments. So for now I am using one of the programs that can put the tablet in host mode for you.

Testing Time! The Device can power the devices, but it will drain your battery faster. I have tested it with USB flash drives, memory card readers, USB hubs, keyboards, and CD-ROM drives All worked fine with no problem (The CD drive had to be manually mounted)


Compiz-Fusion on Fedora 9

Ok, so you have Fedora 9 up and running but now you want all those cool Compiz Effects. Ill show you how!

First off install the Livna repository, It will have your graphics card drivers. (At the time of writing they only have the Nvidia Drivers for Fedora 9, ATI should be out soon) Download and install the RPM http://rpm.livna.org/rlowiki/

Now install your video card driver.

# yum install kmod-nvidia

Now you want to restart X to start using the new driver. You can ether reboot or press <Ctrl> + <Alt> + <Backspace> (Warning: this will log you out immediately.)

From here you can click on System > Preferences > Look and Feel > Desktop Effects and enable them and it should work. But that is just Compiz, not Compiz Fusion.

If you want Compiz Fusion disable the built in Compiz and install these

# yum install compiz-fusion compiz-manager compiz-fusion-extras compiz-fusion-extras-gnome gnome-compiz-manager libcompizconfig compiz-fusion-gnome ccsm compizconfig-backend-gconf

Now that you have them all installed open up System > Preferences > Look and Feel > CompizConfig Settings Manager and Click on Preferences And make sure that “GConf Configuration Backend” is selected. This tells Compiz to use the Gnome window manager.

Now we need to tell Fedora to use Compiz-Fusion instead of just Compiz when it boots up. With your Text editor of choice open up /usr/bin/gnome-wm

# gedit /usr/bin/gnome-wm

Or

# nano /usr/bin/gnome-wm

Look for where it says “gconf” and replace it with “ccp” (no quotes). For me it was on line 129 and looked like this:

OPT4=gconf

Change to:

OPT4=ccp

Now Reboot for the changed on the config file to take affect. Once you have rebooted go back to System > Preferences > Look and Feel > Desktop Effects and Enable the desktop effects, enable the wobbley windows and the desktop cube. They should take affect immediately. And now you can go to System > Preferences > Look and Feel > CompizConfig Settings Manager and enable/disable/change any settings you want. Again the changes will take affect immediately.

You are now done!
A good guide for what most of the Compiz-Fusion plugins can be found herehttp://forlong.blogage.de/article/2008/4/26/How-to-set-up-Compiz-Fusion-074


MPlayer Volume

I use MPlayer to play all my videos and movies on my tablet. That way I dont need to spend the time to convert them to the format the default media player wants. But a problem that I quicky ran into was that unless my surounding enviroment is compoletly silent, I couldent hear anything, even with all the volume bars maxed out. But this was not the case with audio files, I could hear them just fine. So this is how to increase the default max volume in mplayer.

Mplayer uses a config file found in /etc/mplayer/mplayer.conf to get its settings, all we need to do is add 2 lines to it. Here are the 2 lines.

softvol = yes
softvol-max = 500

“softvol = yes” tells MPlayer to use a software volume controll on top of the hardware one. “softvol-max = 500″ Tells it the max value to allow the volume to operate at. It is a percent so 100 would be unchanged, 200 would be double. the max it allows is 10000, but be carfull, if what you are playing is already loud you can dammage your speakers. I dont recomend setting it higher than 500.

I do plan on making a deb that you can install which will automaticky increase your volume, but untill then this is the way to do it.