The way I use SSH

Published on September 25, 2010 by Amir Sedighi

“Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices.” Wikipedia.
That is just an abstract definition. I use SSH to do much more. Here are just some simple commands that I used to run for such a different reasons:

Whenever I need to be somewhere else

ssh -D 8888 root@100.101.102.103

“100.101.102.103″ is just the host that you want to connect it. I assumed that 100.101.102.103 is a SSH enabled machine.
This command simply forwards the remote machine’s HTTP port to my local machine. So I just need to use a socks4 proxy like this : 127.0.0.1:8888.
So whatever you do using your browser will forward to the remote machine. The channel between your local machine and the remote one is pretty secured. However, the remote machine should be trusted.

Whenever I need to call a service that is hosted on a remote machine using a third-one machine
Assume a service such as MYSql or anything else which runs on a machine that is hosted in a remote LAN with [192.168.0.100] IP address. Assume you just can connect to another machine that is hosted in the same LAN using:

ssh root@100.101.102.103

Assume again the service uses the port number 1433.
So, you need to connect to the ssh server machine using ssh root@100.101.102.103 moreover you need to forward 192.168.0.100:1433 to your local machine. This is the simple solution:

ssh -L 1433:192.168.0.100:1433 root@100.101.102.103 -N

The pattern is “ssh -L myPort:host:hostPort”. -N is useful for just forwarding ports and nothing else.
The connections could be same as below map:

your machine           ssh server            remote service
127.0.0.1:1433 .... 100.101.102.103 .... 192.168.0.100:1433

Note:
-Install OpenSSH if you need to provide SSH over Windows servers.
-To access ports under 1024 you should have root privilege.

Posted in Linux

3 Responses to “The way I use SSH”

  1. mohammad Says:

    با سلام خدمت مدیریت سایت
    datispars.com
    با توجه به اینکه شما وبسایت
    http://www.farya.com
    رو طراحی کردید و اونو با سیستم مدیریت وردپرس نوشتین این میل رو براتون فرستادم
    =====
    من یه وب دارم که با وردپرس کارمیکنه
    براش یه قالب جدید درست کردم
    اول مشکل نداشت
    بعد که فایل سینگل رو ساختم واستایل های صفحه سینگل رو یه فایل استایل اصلی اضافه کردم
    سایتم در لاگین شدن با مشکل مواجه شده
    این پیغام میاد
    =================================
    Warning: Cannot modify header information – headers already sent by (output started at /home/abamahdi/domains/abamahdi.com/public_html/wp-content/themes/abamahdiphp/functions.php:1) in /home/abamahdi/domains/abamahdi.com/public_html/wp-login.php on line 337

    Warning: Cannot modify header information – headers already sent by (output started at /home/abamahdi/domains/abamahdi.com/public_html/wp-content/themes/abamahdiphp/functions.php:1) in /home/abamahdi/domains/abamahdi.com/public_html/wp-login.php on line 349
    ================================
    بعد که یوزر وپسورد وارد میکنم این پیغام میاد
    =================================

    Warning: Cannot modify header information – headers already sent by (output started at /home/abamahdi/domains/abamahdi.com/public_html/wp-content/themes/abamahdiphp/functions.php:1) in /home/abamahdi/domains/abamahdi.com/public_html/wp-login.php on line 337

    Warning: Cannot modify header information – headers already sent by (output started at /home/abamahdi/domains/abamahdi.com/public_html/wp-content/themes/abamahdiphp/functions.php:1) in /home/abamahdi/domains/abamahdi.com/public_html/wp-login.php on line 349

    Warning: Cannot modify header information – headers already sent by (output started at /home/abamahdi/domains/abamahdi.com/public_html/wp-content/themes/abamahdiphp/functions.php:1) in /home/abamahdi/domains/abamahdi.com/public_html/wp-includes/pluggable.php on line 690

    Warning: Cannot modify header information – headers already sent by (output started at /home/abamahdi/domains/abamahdi.com/public_html/wp-content/themes/abamahdiphp/functions.php:1) in /home/abamahdi/domains/abamahdi.com/public_html/wp-includes/pluggable.php on line 691

    Warning: Cannot modify header information – headers already sent by (output started at /home/abamahdi/domains/abamahdi.com/public_html/wp-content/themes/abamahdiphp/functions.php:1) in /home/abamahdi/domains/abamahdi.com/public_html/wp-includes/pluggable.php on line 692

    Warning: Cannot modify header information – headers already sent by (output started at /home/abamahdi/domains/abamahdi.com/public_html/wp-content/themes/abamahdiphp/functions.php:1) in /home/abamahdi/domains/abamahdi.com/public_html/wp-includes/pluggable.php on line 890
    =============
    نمیدونم مشکل از کجاست
    وضعیت فایل استایل رو به حالت قبل برگشت دادم ولی فایده ایی نداشت
    البته کاری هم به اسایل نداره
    استایل هرچی ایندکس فراخوانی بکنه اطلاعات میده
    وقتی فایل فانشن رو از پوشه برداشتم دیگه به راحتی لاگین میشم
    البته حالا دیگه فایل فانشن رو ندارم
    و میدنید که بدون فانشن هم نمیشه

    خواستم لطف بفرمائید ما رو راهنمایی بفرمائید
    اجرتون با اهل بیت(ع)
    سایتی ساختیم در باب نشر معارف اهل بیت
    حالا با مشکل برخورد کردیم
    فایل ها رو براتون ضمیمه ایمیل کردم
    در ضمن حالا سایت به خوبی بالا میاد

    باتشکر-منتظر ایمیلتون هستم
    محمدموثق پور
    از شهرستان بهبهان
    09358670260

    http://www.abamahdi.com
    هیئت محبین امام حسن عسکری (ع) شهرستان بهبهان

  2. mohammad Says:

    آقای امیر صادقی
    براتون یه ایمیل هم فرستادم
    ان شاء الله که ما رو راهنمایی میفرمائید
    یا علی

  3. محمدموثق پور Says:

    سلام
    من یه مشکلی در بخش دفترکار وردپرسم دارم
    ابزارکها کارنمیکنه
    تو صفحه مدیریت ابزارکها نمیره
    ولی وقتی روش کلیک می کنم
    بازنمیشه
    تو استراتوس بار
    مینویسه اشکال در صفحه
    کلافه شدم
    نمیدونم چه مرگشه
    ببخشید
    هر مشکلی رو رد میکنم
    یه مشکل دیگه
    اما لذت بخشه.ساخت یه وب سایت کار جالبیه
    البته مشکلات زیادی داره
    یه بار لطف کردید مشکل مارو خوب حل کردید
    اینبار هم یه راهنمایی کنید
    باتشکر
    منظر جوابتون هستم
    فایل فانشنم رو هم براتون میلکردم به
    info@…
    باتشکر

Leave a Reply

Categories

Archives