Posts Tagged ‘ssh’

X11 Forwarding

A few days, I moved my desktop computer out into the living room. The computer has a tuner card that can receive digital broadcasts. I don’t own a TV, so this is the closest I’ve got to one. I still have to set up lircd before I can use a remote, but I wanted something a bit easier

Today, I discovered a new trick … SSH X11 Forwarding. Now, I can play video on my desktop right from my netbook. It’s wonderful and very simple!

In the following instructions, the “A” refers to the computer playing the video and “B” refers to any other computer.

  1. Make sure “X11Forwarding Yes” is in your sshd_config file on computer A. Restart sshd if you had to uncomment/add it.
  2. On B, run `ssh -XC A`
  3. In the ssh session, type `DISPLAY=:0.0`.
  4. Now run mplayer or any other video player in the  ssh session and it will play on computer A.

If you want  to have a program run on computer A and use the screen on computer B, the process is very similar:

  1. Make sure “X11Forwarding Yes” is in your sshd_config file on computer A. Restart sshd if you had to uncomment/add it.
  2. On B, run `xhost A`
  3. On B, run `ssh -XC A`
  4. Now run mplayer or any other video player in the  ssh session and it will play on computer A.

Step 2 authorizes use of the current display by computer A and only needs to be run once. Also, note that the display variable doesn’t need to be set when using B’s screen.

Mplayer works wonderfully when playing on my desktop, plus I control it via the ssh session. It has tons of keyboard shortcuts. The ones I use the most are space for pause and the arrow keys for skipping around.

Be the first to comment - What do you think?

Posted by James    Date: Monday, January 11, 2010

Categories: Linux, Networks, Tips

Tags: , ,

SSH Without a Password

You can ssh from one box to another without typing in your password. This is done using a key pair. One key sits on the computer A, the other on computer B. Starting logged into computer A, here’s how you do it:

ssh-keygen -t dsa
ssh B mkdir ~/.ssh/
cat .ssh/id_dsa.pub | ssh B 'cat >> .ssh/authorized_keys'

When you run ssh-keygen, do not use a passphrase, just press enter. Also, change the bold B to the name or IP of computer B. If you were successful, you should be able to `ssh B` without a password.

To repeat for another computer, do not repeat ssh-keygen, just repeat line 2 & 3. If you run ssh-keygen again, your key will be overwritten and you’ll need to copy it again via line 3.

Using keys is an excellent security measure. You can even setup sshd to only allow keyed logins. No passwords allowed. If you do set this up, make sure you have physical access or a rescue/remote console or you’ll be locked out if you lose your key.

Be the first to comment - What do you think?

Posted by James    Date: Thursday, December 17, 2009

Categories: Linux, Tips

Tags: , ,