How to find the version of an Ubuntu machine remotely?

Solution 1:

You can get the Ubuntu version using

$ lsb_release -s -d
Ubuntu 10.04.1 LTS

If you want to automate that, write a Bash script that reads list of hosts from stdin and executes the command over SSH. Something like

#!/bin/bash
while read host; do
   echo -n "$host: "
   ssh "$host" lsb_release -s -d < /dev/null
done

If you have one common user account on all the machines you want to connect to then this should be what you are looking for

#!/bin/bash
RUSER="username"
while read host; do
   echo -n "$host: "
   ssh "$RUSER@$host" lsb_release -s -d < /dev/null
done

Save it as versions.sh, remembering to make it executable (chmod a+x versions.sh), and execute

$ versions.sh < ips.txt

Solution 2:

Assuming they are running SSH servers, you could try to guess Ubuntu versions based on the package version of SSH:

$ nc IP.IP.IP.IP 22
SSH-2.0-OpenSSH_5.5p1 Debian-4ubuntu5
Ctrl-C

Current versions of openssh are listed in Launchpad https://launchpad.net/distros/ubuntu/+source/openssh:

openssh | 1:4.2p1-7ubuntu3.5 | dapper-updates/main
openssh | 1:4.7p1-8ubuntu3   | hardy-updates/main
openssh | 1:5.1p1-6ubuntu2   | karmic/main
openssh | 1:5.3p1-3ubuntu6   | lucid-updates/main
openssh | 1:5.5p1-4ubuntu5   | maverick-updates/main
openssh | 1:5.8p1-1ubuntu2   | natty/main

So in my above example, 5.5p1 with a Debian version of -4ubuntu5 looks to be an Ubuntu 10.10 Maverick system.

Some servers may have "DebianBanner no" in their /etc/ssh/sshd_config file, but the upstream version of OpenSSH is still visible which is sufficient to identify the system still (each release of Ubuntu so far has a different upstream version of OpenSSH).