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.

Finding a PC on your network

Filed under: General Linux,Linux Software — TheLinuxBlog.com at 4:31 am on Tuesday, September 4, 2007

When I’m at a remote location I sometimes need to gain access to a computer that is not accessible from the internet but is on the same network as another machine that is. I have remote SSH access into the box that is on the same network but I often don’t know the IP address for the computer that I am trying to gain access to since they are assigned via DHCP.
I have a simple solution that will locate the computer I wish to use once logged into the gateway in no time. The program needed is from our friends at insecure.org and is called nmap. It is a pretty standard tool so it should be included with your distribution. However if you do not own the Linux machine then it may not be installed or you may not have the ability to install it or have sufficient privileges to run it.
Basically what nmap does is scan the network.
The command I use to scan a whole subnet for my host is:

nmap -sP 192.168.x.x/24

The type of scan I use is a ping scan, I only determine if the host is online. If I know the DHCP pool starts from 1.1 and ends at 1.100 then I would use:

nmap -sP 192.168.1.1-100

This will yield faster scanning results since it only has to ping 100 hosts not the whole subnet.
Sometimes if the environment is a busy one (one with lots of hosts) a lot of online IP’s will be returned and its hard to identify which one your trying to connect to. I remedy this by just scanning the host range I need that only have port 22 open.

nmap 192.168.3.1-100 -sT -p22

The -sT option doesn’t require the user to be root but if you have root the -sS option is better as it gives detailed information such as the mac address which can come in handy if you happen to know what brand of network card is in the computer you are trying to log into.

This will work to find a computer on a network with Linux but it still requires you to know a little information about the PC your trying to find. If you need a better way of finding your PC’s I would recommend using static IP’s and DNS. Give it a shot if your on location somewhere and need access to your computer.