{"id":13547,"date":"2019-04-03T10:23:54","date_gmt":"2019-04-03T10:23:54","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13547"},"modified":"2019-04-03T10:23:54","modified_gmt":"2019-04-03T10:23:54","slug":"how-to-access-a-remote-server-using-a-jump-host","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/03\/how-to-access-a-remote-server-using-a-jump-host\/","title":{"rendered":"How to Access a Remote Server Using a Jump Host"},"content":{"rendered":"<p>A\u00a0<strong>jump host<\/strong>\u00a0(also known as a\u00a0<strong>jump server<\/strong>) is an intermediary host or an SSH gateway to a remote network, through which a connection can be made to another host in a dissimilar security zone, for example a demilitarized zone (<strong>DMZ<\/strong>). It bridges two dissimilar security zones and offers controlled access between them.<\/p>\n<p>A\u00a0<strong>jump host<\/strong>\u00a0should be highly secured and monitored especially when it spans a private network and a\u00a0<strong>DMZ<\/strong>\u00a0with servers providing services to users on the internet.<\/p>\n<p>A classic scenario is connecting from your desktop or laptop from inside your company\u2019s internal network, which is highly secured with firewalls to a DMZ. In order to easily manage a server in a DMZ, you may access it via a\u00a0<strong>jump host<\/strong>.<\/p>\n<p>In this article, we will demonstrate how to access a remote Linux server via a\u00a0<strong>jump host<\/strong>\u00a0and also we will configure necessary settings in your per-user SSH client configurations.<\/p>\n<p>Consider the following scenario.<\/p>\n<div id=\"attachment_31124\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/SSH-Jump-Host.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31124\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/SSH-Jump-Host.png\" sizes=\"auto, (max-width: 1042px) 100vw, 1042px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/SSH-Jump-Host.png 1042w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/SSH-Jump-Host-768x212.png 768w\" alt=\"SSH Jump Host\" width=\"1042\" height=\"288\" aria-describedby=\"caption-attachment-31124\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-31124\" class=\"wp-caption-text\">SSH Jump Host<\/p>\n<\/div>\n<p>In above scenario, you want to connect to\u00a0<strong>HOST 2<\/strong>, but you have to go through\u00a0<strong>HOST 1<\/strong>, because of firewalling, routing and access privileges. There is a number of valid reasons why jumphosts are needed..<\/p>\n<h3>Dynamic Jumphost List<\/h3>\n<p>The simplest way to connect to a target server via a\u00a0<strong>jump host<\/strong>\u00a0is using the\u00a0<code>-J<\/code>\u00a0flag from the command line. This tells ssh to make a connection to the jump host and then establish a TCP forwarding to the target server, from there (make sure you\u2019ve\u00a0<a href=\"https:\/\/www.tecmint.com\/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps\/\" target=\"_blank\" rel=\"noopener\">Passwordless SSH Login<\/a>\u00a0between machines).<\/p>\n<pre>$ ssh -J host1 host2\r\n<\/pre>\n<p>If\u00a0<strong>usernames<\/strong>\u00a0or\u00a0<strong>ports<\/strong>\u00a0on machines differ, specify them on the terminal as shown.<\/p>\n<pre>$ ssh -J username@host1:port username@host2:port\t  \r\n<\/pre>\n<h3>Multiple Jumphosts List<\/h3>\n<p>The same syntax can be used to make jumps over multiple servers.<\/p>\n<pre>$ ssh -J username@host1:port,username@host2:port username@host3:port\r\n<\/pre>\n<h3>Static Jumphost List<\/h3>\n<p>Static jumphost list means, that you know the\u00a0<strong>jumphost<\/strong>\u00a0or\u00a0<strong>jumphosts<\/strong>\u00a0that you need to connect a machine. Therefore you need to add the following static jumphost \u2018routing\u2019 in\u00a0<code>~\/.ssh\/config<\/code>\u00a0file and specify the host aliases as shown.<\/p>\n<pre>### First jumphost. Directly reachable\r\nHost <strong>vps1<\/strong>\r\n  HostName vps1.example.org\r\n\r\n### Host to jump to via jumphost1.example.org\r\nHost <strong>contabo<\/strong>\r\n  HostName contabo.example.org\r\n  ProxyJump contabo\r\n<\/pre>\n<p>Now try to connect to a target server via a\u00a0<strong>jump host<\/strong>\u00a0as shown.<\/p>\n<pre>$ ssh -J vps1 contabo\r\n<\/pre>\n<div id=\"attachment_31125\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/login-into-target-host-via-jumphost.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31125\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/login-into-target-host-via-jumphost.png\" sizes=\"auto, (max-width: 842px) 100vw, 842px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/login-into-target-host-via-jumphost.png 842w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/11\/login-into-target-host-via-jumphost-768x314.png 768w\" alt=\"Login to Target Host via Jumphost\" width=\"842\" height=\"344\" aria-describedby=\"caption-attachment-31125\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-31125\" class=\"wp-caption-text\">Login to Target Host via Jumphost<\/p>\n<\/div>\n<p>The second method is to use the\u00a0<strong>ProxyCommand<\/strong>\u00a0option to add the\u00a0<strong>jumphost<\/strong>\u00a0configuration in your\u00a0<code>~.ssh\/config<\/code>\u00a0or\u00a0<code>$HOME\/.ssh\/config<\/code>\u00a0file as shown.<\/p>\n<p>In this example, the target host is\u00a0<strong>contabo<\/strong>\u00a0and the\u00a0<strong>jumphost<\/strong>\u00a0is\u00a0<strong>vps1<\/strong>.<\/p>\n<pre>Host vps1\r\n\tHostName vps1.example.org\r\n\tIdentityFile ~\/.ssh\/vps1.pem\r\n\tUser ec2-user\r\n\r\nHost contabo\r\n\tHostName contabo.example.org\t\r\n\tIdentityFile ~\/.ssh\/contabovps\r\n\tPort 22\r\n\tUser admin\t\r\n\t<strong>Proxy Command ssh -q -W %h:%p vps1<\/strong>\r\n<\/pre>\n<p>Where the command\u00a0<code>Proxy Command ssh -q -W %h:%p vps1<\/code>, means run ssh in quiet mode (using\u00a0<code>-q<\/code>) and in stdio forwarding (using\u00a0<code>-W<\/code>) mode, redirect the connection through an intermediate host (<strong>vps1<\/strong>).<\/p>\n<p>Then try to access your target host as shown.<\/p>\n<pre>$ ssh contabo\r\n<\/pre>\n<p>The above command will first open an ssh connection to\u00a0<strong>vps1<\/strong>\u00a0in the background effected by the\u00a0<strong>ProxyCommand<\/strong>, and there after, start the ssh session to the target server\u00a0<strong>contabo<\/strong>.<\/p>\n<p>For more information, see the ssh man page or refer to:\u00a0<a href=\"https:\/\/en.wikibooks.org\/wiki\/OpenSSH\/Cookbook\/Proxies_and_Jump_Hosts\" target=\"_blank\" rel=\"nofollow noopener\">OpenSSH\/Cookbxook\/Proxies and Jump Hosts<\/a>.<\/p>\n<p>That\u2019s all for now! In this article, we have demonstrated how to access a remote server via a jump host. Use the feedback form below to ask any questions or share your thoughts with us.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/access-linux-server-using-a-jump-host\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A\u00a0jump host\u00a0(also known as a\u00a0jump server) is an intermediary host or an SSH gateway to a remote network, through which a connection can be made to another host in a dissimilar security zone, for example a demilitarized zone (DMZ). It bridges two dissimilar security zones and offers controlled access between them. A\u00a0jump host\u00a0should be highly &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/03\/how-to-access-a-remote-server-using-a-jump-host\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Access a Remote Server Using a Jump Host&#8221;<\/span><\/a><\/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":[],"class_list":["post-13547","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13547","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=13547"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13547\/revisions"}],"predecessor-version":[{"id":13551,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13547\/revisions\/13551"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13547"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13547"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13547"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}