Linux Blog

Using Subversion with SSH & Custom Ports

Filed under: Linux Software,Quick Linux Tutorials — TheLinuxBlog.com at 9:09 am on Monday, September 15, 2008

Lets say you use subversion on your home PC to keep track of projects and you want to checkout or export your project from a remote location. Here’s the catch, sshd is running on a custom port or forwarded from another. For some reason the command line SVN client does not support a port parameter when using the defacto svn+ssh://

svn co svn+ssh://thelinuxblog.com/owen/svn/project1/trunk project1
ssh: connect to host thelinuxblog.com port 22: Connection refused

Well we know why the error above happens its because I happen to run SSH on port 1337. The following work around requires root privileges, and may mess with your system a bit but if you really need to check something out, then it will work.

As root, login and stop SSH if you run it. With SSH Forward port 22 with a local SSH forwarding connection to the remote host.

[owen@thelinuxblog.com]$ sudo su -
[root@thelinuxblog.com]$ /sbin/service sshd stop
[root@thelinuxblog.com]$ ssh -p 1337 owen@thelinuxblog.com-L 22:[internal ip]:1337

Once this is done, your localhost:22 now forwards to your remote host. With another session (on your local machine) you can verify the connection by using ssh localhost. You will probably get warnings about the hosts identity being changed, or not verifying it, but you can ignore then. Once you’ve tested it, just use SVN as normal. When finished, remember to logout of the SSH session, and start SSH back up again if you run it.

Two Screens, Two Linux Boxes – One Keyboard and Mouse

Filed under: General Linux,Quick Linux Tutorials — TheLinuxBlog.com at 8:50 am on Wednesday, September 26, 2007

Ever wished you could use your keyboard and mouse on another computer? In this article I will show you how.
To read it it should take about 60 seconds. In this time I’ll show you how to use one keyboard and mouse on two Linux machines. I’ll cover how to use the same keyboard and mouse on a Linux and Windows machine in another article.

Ready? Lets go!

First Decide which keyboard and mouse you want to use across multiple monitors on different machines and sit at that computer. The program needed to get this to work is called x2x.
As of this writing the stable version is 1.27

Download the stable version from http://x2x.dottedmag.net/

wget http://x2x.dottedmag.net/releases/x2x-1.27.tar.gz

Extract The Source code

tar xvzf x2x-1.27.tar.gz

Compile x2x

./configure && make && make install

If x2x compiled without any errors you should be good to run the program.
On the computer you want to use your primary keyboard and mouse on do the following:
Find out your IP

/sbin/ifconfig ethX

Run xhost to allow clients to connect to your display:

xhost +

Going back to your original computer decide which side of the monitor you want your mouse to jump to the other computer on. It will either be North, South, East or West. If your second linux box is on your left like mine, it will be west.
Now lets get the two computers connected with the same keyboard and mouse:

x2x 192.168.X.X:0.0 -west

Thats all there is to it. You should be able to mouse over the right of your screen and see your mouse cursor on the other computer.

Bringing The Internet Up After Failure

Filed under: Shell Script Sundays — TheLinuxBlog.com at 9:58 pm on Sunday, September 9, 2007

This Shell Script Sunday is a short one but don’t let that fool you to the power of the shell. This script I wrote earlier in the week due to power spikes at the office. All of our equipment would stay powered on due to UPS’s but unfortunately something with the ISP was not staying on. Once the brownout occurred our router box would still have an IP and seem to be working but it wouldn’t. We had our suspicions about what piece of equipment it was but had no power to fix it. I would renew the IP from the ISP bring the public interface down by using eth0 down and then eth0 up but this was not successful. To fix it from the router I had to actually reset the network. This worked, but we have some services running at the office that I like to access from home. So to fix the problem I wrote a one liner to reset the network if the connection goes down.

ping -c 1 OurISP.com 2> /dev/null > /dev/null && echo > /dev/null || sudo /etc/rc.d/network restart

The techniques in this script are covered in Shell Scripting 101. All this does is ping OurISP.com one time and output the error & standard output to /dev/null. If the ping was successful it does nothing and if the ping failed then it restarts the network. To get it to repeat at an interval I just set it up as a cron job. This did the trick and I now do not have to worry about brownouts.