{"id":311,"date":"2020-05-14T16:24:29","date_gmt":"2020-05-14T14:24:29","guid":{"rendered":"https:\/\/anjo.pt\/wp\/keyword-oracle\/?p=311"},"modified":"2020-05-14T16:36:26","modified_gmt":"2020-05-14T14:36:26","slug":"ssh-tips-tricks","status":"publish","type":"post","link":"https:\/\/anjo.pt\/keyword-oracle\/2020\/05\/14\/ssh-tips-tricks\/","title":{"rendered":"SSH tips &#038; tricks"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">These days I&#8217;ve been playing with Oracle Cloud and Azure. It is best practice to have a bastion or jumphost server with public IP address and all the rest on private networks, only accessible internally.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, there is no use of passwords and only the ssh public key of the user is located on the servers. Usually this is what we try to do:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"518\" height=\"476\" src=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-5.png\" alt=\"\" class=\"wp-image-318\" srcset=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-5.png 518w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-5-300x276.png 300w\" sizes=\"auto, (max-width: 518px) 100vw, 518px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To start with, I use <a rel=\"noreferrer noopener\" href=\"https:\/\/mobaxterm.mobatek.net\/\" target=\"_blank\">MobaXterm<\/a> to access my servers. There I&#8217;ve configured my SSH private keys to be loaded:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"668\" height=\"540\" src=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-1.png\" alt=\"MobaXterm configuration menu for SSH\" class=\"wp-image-313\" srcset=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-1.png 668w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-1-300x243.png 300w\" sizes=\"auto, (max-width: 668px) 100vw, 668px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Connect to jumphost server and take SSH key<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use the -A option when connecting:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ssh -A opc@bastion-server<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"> Then you can do ssh to the next server in the private subnet without password. Example of not using and using this option:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"832\" height=\"201\" src=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-2.png\" alt=\"\" class=\"wp-image-314\" srcset=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-2.png 832w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-2-300x72.png 300w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-2-768x186.png 768w\" sizes=\"auto, (max-width: 832px) 100vw, 832px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Connect to private server via jumphost directly<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For this we use both -A and -J options:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ssh -A -J opc@bastion-server opc@private-server<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"932\" height=\"70\" src=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-3.png\" alt=\"\" class=\"wp-image-315\" srcset=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-3.png 932w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-3-300x23.png 300w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-3-768x58.png 768w\" sizes=\"auto, (max-width: 932px) 100vw, 932px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">SCP directly to private server via JumpHost<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Here we have to use a ProxyJump option of scp in this case:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">scp -o 'ProxyJump opc@bastion-server' file.zip opc@private-server:~\/<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"46\" src=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-4-1024x46.png\" alt=\"\" class=\"wp-image-316\" srcset=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-4-1024x46.png 1024w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-4-300x14.png 300w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-4-768x35.png 768w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2020\/05\/image-4.png 1147w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>These days I&#8217;ve been playing with Oracle Cloud and Azure. It is best practice to have a bastion or jumphost server with public IP address and all the rest on private networks, only accessible internally. Also, there is no use of passwords and only the ssh public key of the user is located on the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53,51,35,52],"tags":[],"class_list":["post-311","post","type-post","status-publish","format-standard","category-azure","category-cloud","category-linux","category-oci","czr-hentry"],"_links":{"self":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/comments?post=311"}],"version-history":[{"count":2,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/311\/revisions"}],"predecessor-version":[{"id":319,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/311\/revisions\/319"}],"wp:attachment":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/media?parent=311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/categories?post=311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/tags?post=311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}