{"id":437,"date":"2011-11-23T17:39:15","date_gmt":"2011-11-23T16:39:15","guid":{"rendered":"http:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/"},"modified":"2011-11-23T17:39:15","modified_gmt":"2011-11-23T16:39:15","slug":"how-to-detect-the-debian-version-of-a-server-without-logging-in","status":"publish","type":"post","link":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/","title":{"rendered":"How to detect the Debian version of a server without logging in"},"content":{"rendered":"<p>As Ops team, we&#39;re slowly taking over operations for several other teams here at Opera. One of our first tasks is to:<\/p>\n<p><span class='imgcenter'><img alt='' src='http:\/\/files.myopera.com\/cstrep\/blog\/upgrade-all-the-lennys.jpg' \/><\/span><\/p>\n<p>First idea to check whether a server is Debian Lenny or Squeeze was to login and cat <code>\/etc\/debian_version<\/code>. However, if you haven&#39;t accessed that machine before, and your ssh keys are not there, you can&#39;t do that. In our case, we have to file a request for it, and it can take time. Wondering if there was a quicker way, I came up with this trick:<\/p>\n<pre>\r\n#!\/bin\/sh\r\n#\r\n# Tells the Debian version reading the OpenSSH banner\r\n# Requires OpenSSH to be running and ssh port to be open.\r\n#\r\n# Usage: $0 &lt;hostname&gt;\r\n#\r\n# Cosimo, 23\/11\/2011\r\n\r\nHOST=$1\r\n\r\nif [ &quot;x$HOST&quot; = &quot;x&quot; ]; then\r\n    echo &quot;Usage: $0 &lt;hostname&gt;&quot;\r\nfi\r\n\r\nOPENSSH_BANNER=$(echo &quot;n&quot; | nc ${HOST} 22 | head -1)\r\n\r\n#echo &quot;OPENSSH_BANNER=$OPENSSH_BANNER&quot;\r\n\r\nIS_SQUEEZE=$(echo $OPENSSH_BANNER | egrep &#39;^SSH-.*OpenSSH_5.*Debian-6&#39;)\r\nIS_LENNY=$(echo $OPENSSH_BANNER   | egrep &#39;^SSH-.*OpenSSH_5.*Debian-5&#39;)\r\nIS_ETCH=$(echo $OPENSSH_BANNER    | egrep &#39;^SSH-.*OpenSSH_4.*Debian-9&#39;)\r\n\r\n# SSH-2.0-OpenSSH_5.1p1 Debian-5\r\n# SSH-2.0-OpenSSH_4.3p2 Debian-9etch3\r\n# SSH-2.0-OpenSSH_5.5p1 Debian-6+squeeze1\r\n\r\n#echo &quot;Squeeze: $IS_SQUEEZE&quot;\r\n#echo &quot;Lenny: $IS_LENNY&quot;\r\n#echo &quot;Etch: $IS_ETCH&quot;\r\n\r\nif [ &quot;x$IS_SQUEEZE&quot; != &quot;x&quot; ]; then\r\n    echo &quot;$HOST is Debian 6.x (squeeze)&quot;\r\n    exit 0\r\nfi\r\n\r\nif [ &quot;x$IS_LENNY&quot; != &quot;x&quot; ]; then\r\n    echo &quot;$HOST is Debian 5.x (lenny)&quot;\r\n    exit 0\r\nfi\r\n\r\nif [ &quot;x$IS_ETCH&quot; != &quot;x&quot; ]; then\r\n    echo &quot;$HOST is Debian 4.x (etch)&quot;\r\n    exit 0\r\nfi\r\n\r\necho &quot;I don&#39;t know what $HOST is.&quot;\r\necho &quot;Here&#39;s the openssh banner: &#39;$OPENSSH_BANNER&#39;&quot;\r\n\r\nexit 1\r\n<\/pre>\n<p>It reads the OpenSSH server banner to determine the major Debian version (Etch, Lenny, Squeeze). It&#39;s really fast, it&#39;s very simple and hopefully reliable too. Enjoy. Download from <a href=\"https:\/\/gist.github.com\/1389206\/\" title=\"check-debian-version.sh\" rel=\"nofollow\">https:\/\/gist.github.com\/1389206\/<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As Ops team, we&#39;re slowly taking over operations for several other teams here at Opera. One of our first tasks is to: First idea to check whether a server is Debian Lenny or Squeeze was to login and cat \/etc\/debian_version. However, if you haven&#39;t accessed that machine before, and your ssh keys are not there, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[254,248,242,253,219,255,76,251,252],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to detect the Debian version of a server without logging in - Random hacking<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to detect the Debian version of a server without logging in - Random hacking\" \/>\n<meta property=\"og:description\" content=\"As Ops team, we&#039;re slowly taking over operations for several other teams here at Opera. One of our first tasks is to: First idea to check whether a server is Debian Lenny or Squeeze was to login and cat \/etc\/debian_version. However, if you haven&#039;t accessed that machine before, and your ssh keys are not there, [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/\" \/>\n<meta property=\"og:site_name\" content=\"Random hacking\" \/>\n<meta property=\"article:published_time\" content=\"2011-11-23T16:39:15+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/files.myopera.com\/cstrep\/blog\/upgrade-all-the-lennys.jpg\" \/>\n<meta name=\"author\" content=\"cosimo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"cosimo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/\"},\"author\":{\"name\":\"cosimo\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1\"},\"headline\":\"How to detect the Debian version of a server without logging in\",\"datePublished\":\"2011-11-23T16:39:15+00:00\",\"dateModified\":\"2011-11-23T16:39:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/\"},\"wordCount\":136,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1\"},\"image\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/files.myopera.com\/cstrep\/blog\/upgrade-all-the-lennys.jpg\",\"keywords\":[\"bash\",\"debian\",\"devops\",\"lenny\",\"operations\",\"ops\",\"servers\",\"sh\",\"squeeze\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/\",\"url\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/\",\"name\":\"How to detect the Debian version of a server without logging in - Random hacking\",\"isPartOf\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/files.myopera.com\/cstrep\/blog\/upgrade-all-the-lennys.jpg\",\"datePublished\":\"2011-11-23T16:39:15+00:00\",\"dateModified\":\"2011-11-23T16:39:15+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/#primaryimage\",\"url\":\"http:\/\/files.myopera.com\/cstrep\/blog\/upgrade-all-the-lennys.jpg\",\"contentUrl\":\"http:\/\/files.myopera.com\/cstrep\/blog\/upgrade-all-the-lennys.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.streppone.it\/cosimo\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to detect the Debian version of a server without logging in\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#website\",\"url\":\"https:\/\/www.streppone.it\/cosimo\/blog\/\",\"name\":\"Random hacking\",\"description\":\"Assume nothing. Code defensively. Keep it simple, stupid!\",\"publisher\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.streppone.it\/cosimo\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1\",\"name\":\"cosimo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cb1d938720df45a2720724aae99e3bfc?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cb1d938720df45a2720724aae99e3bfc?s=96&r=g\",\"caption\":\"cosimo\"},\"logo\":{\"@id\":\"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/image\/\"},\"url\":\"https:\/\/www.streppone.it\/cosimo\/blog\/author\/cosimo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to detect the Debian version of a server without logging in - Random hacking","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/","og_locale":"en_US","og_type":"article","og_title":"How to detect the Debian version of a server without logging in - Random hacking","og_description":"As Ops team, we&#39;re slowly taking over operations for several other teams here at Opera. One of our first tasks is to: First idea to check whether a server is Debian Lenny or Squeeze was to login and cat \/etc\/debian_version. However, if you haven&#39;t accessed that machine before, and your ssh keys are not there, [&hellip;]","og_url":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/","og_site_name":"Random hacking","article_published_time":"2011-11-23T16:39:15+00:00","og_image":[{"url":"http:\/\/files.myopera.com\/cstrep\/blog\/upgrade-all-the-lennys.jpg"}],"author":"cosimo","twitter_card":"summary_large_image","twitter_misc":{"Written by":"cosimo","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/#article","isPartOf":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/"},"author":{"name":"cosimo","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1"},"headline":"How to detect the Debian version of a server without logging in","datePublished":"2011-11-23T16:39:15+00:00","dateModified":"2011-11-23T16:39:15+00:00","mainEntityOfPage":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/"},"wordCount":136,"commentCount":0,"publisher":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1"},"image":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/#primaryimage"},"thumbnailUrl":"http:\/\/files.myopera.com\/cstrep\/blog\/upgrade-all-the-lennys.jpg","keywords":["bash","debian","devops","lenny","operations","ops","servers","sh","squeeze"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/","url":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/","name":"How to detect the Debian version of a server without logging in - Random hacking","isPartOf":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/#primaryimage"},"image":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/#primaryimage"},"thumbnailUrl":"http:\/\/files.myopera.com\/cstrep\/blog\/upgrade-all-the-lennys.jpg","datePublished":"2011-11-23T16:39:15+00:00","dateModified":"2011-11-23T16:39:15+00:00","breadcrumb":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/#primaryimage","url":"http:\/\/files.myopera.com\/cstrep\/blog\/upgrade-all-the-lennys.jpg","contentUrl":"http:\/\/files.myopera.com\/cstrep\/blog\/upgrade-all-the-lennys.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/2011\/11\/how-to-detect-the-debian-version-of-a-server-without-logging-in\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.streppone.it\/cosimo\/blog\/"},{"@type":"ListItem","position":2,"name":"How to detect the Debian version of a server without logging in"}]},{"@type":"WebSite","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#website","url":"https:\/\/www.streppone.it\/cosimo\/blog\/","name":"Random hacking","description":"Assume nothing. Code defensively. Keep it simple, stupid!","publisher":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.streppone.it\/cosimo\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/c443bedbf6ecf99550d6395620801df1","name":"cosimo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cb1d938720df45a2720724aae99e3bfc?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cb1d938720df45a2720724aae99e3bfc?s=96&r=g","caption":"cosimo"},"logo":{"@id":"https:\/\/www.streppone.it\/cosimo\/blog\/#\/schema\/person\/image\/"},"url":"https:\/\/www.streppone.it\/cosimo\/blog\/author\/cosimo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/posts\/437"}],"collection":[{"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/comments?post=437"}],"version-history":[{"count":0,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/posts\/437\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/media?parent=437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/categories?post=437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.streppone.it\/cosimo\/blog\/wp-json\/wp\/v2\/tags?post=437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}