LoginSignup
11
2

More than 3 years have passed since last update.

remote.it CLIの使い方

Posted at

1. 今回の要約

  • remote.it CLI ソフトウェアを取得する
  • remote.it CLIを使用して、Linuxへremote.itをインストールする
  • remote.it CLIを使用して、デバイスとサービスを登録する
  • remote.it CLIを使用して、他のremote.itデバイスへ接続する
  • remote.it CLI の使い方全般を学ぶ

remote.itには、GUIを備えたクライアントソフトウェアとしてremtoe.it Desktop Appがあります。このグラフィカルなインタフェースは、Windows/macOS/Debian Linuxなどで使うことができます。
※headless Admin Panel serviceという、WebUIが用意されているものもあります

一方、その他のLinuxOSやCLIしか使用できないサーバ環境などでは、remote.it CLIが利用できます。
※remote.it CLIは、Desktop Appにも付属しています

本稿では、remote.it CLIの利用方法について説明します。
※remote.it CLI 1.6.36での確認を行っているため、将来的に動作が変更になる場合があります

2. remote.it CLIソフトウェアを取得する

remote.it CLIソフトウェアは、remote.itのダウンロードページ(https://remote.it/downloads/)の中の「CLI」から取得できます。

また、各種プラットフォーム用のremote.it CLIソフトウェアを直接入手する際のURLは、以下を確認ください。

3. remote.it CLIを使用して、Linuxへremote.itをインストールする

CLIのインストール

  • 今回は、Linux/amd64用のソフトウェアを使用します。インストールを行うLinuxにログインをして、remote.it CLIをダウンロードしてください。
$ curl -LkO https://downloads.remote.it/cli/latest/remoteit_linux_x86_64
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 3011k  100 3011k    0     0  2041k      0  0:00:01  0:00:01 --:--:-- 8340k
$
$ ls -l
total 3016
-rw-r--r-- 1 root root 3083868 Feb 15 06:40 remoteit_linux_x86_64
  • ダウンロードしたremote.it CLIを、実行パスの通ったディレクトリにコピーします(併せて、ファイル名を修正します)。コピーしたファイルに実行権限を付与してください。
$ sudo cp remoteit_linux_x86_64 /usr/bin/remoteit
$ sudo chmod +x /usr/bin/remoteit
$
$ ls -l /usr/bin/remoteit
-rwxr-xr-x 1 root root 3083868 Feb 15 06:42 /usr/bin/remoteit
  • remote.it CLIが正しく配置されたことを確認します。
$ sudo remoteit version
1.6.36

CLIサービスの登録と関連ツールのインストール

  • remote.it CLIサービスをsystemdに登録します。
$ sudo remoteit agent install
 ? Installed and started system service successfully
$
$ sudo systemctl status it.remote.cli
● it.remote.cli.service - remote.it agent, manages connections
     Loaded: loaded (/etc/systemd/system/it.remote.cli.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2021-02-15 06:44:25 UTC; 9s ago
       Docs: https://docs.remote.it
   Main PID: 2493 (remoteit)
      Tasks: 14 (limit: 535)
     Memory: 17.1M
     CGroup: /system.slice/it.remote.cli.service
()

Feb 15 06:44:25 ip-10-0-2-152 systemd[1]: Started remote.it agent, manages connections.
  • 次に、remote.it CLIを利用して、関連バイナリのインストールを行います。
$ sudo remoteit tools install
 ? Installing tools
 ? Tools installed to: '/usr/bin'
$
$ ls -l /usr/bin |grep -e remoteit -e connectd -e muxer
-rwxr-xr-x 1 root   root      166968 Jan 18 05:08 connectd
-rwxr-xr-x 1 root   root        7588 Jan 18 05:07 connectd_options
-rwxr-xr-x 1 root   root        6722 Feb 15 06:44 connectd_task_notify
-rwxr-xr-x 1 root   root       34808 Jan 18 05:08 demuxer
-rwxr-xr-x 1 root   root       30712 Jan 18 05:08 muxer
-rwxr-xr-x 1 root   root     3083868 Feb 15 06:42 remoteit

remote.it へのサインイン

  • 最後に、remote.itアカウントでのサインインを行います。
$ sudo remoteit signin
Username: xxxxxxxx@stylez.co.jp [remote.itアカウントを入力]
Password:
 ? SIGNIN in progress ...
 ? Login with remote.it account
 ? Download & install dependencies
 ? NEXT-ACTION: run 'remoteit register' to register this device into your remote.it account
  • remoteit statusコマンドを使用すると、サインインされたことが確認できます。 ※Usernameに、サインインされたアカウントが表示されます
$ sudo remoteit status
 ? Fetching status

Username: xxxxxxxx@stylez.co.jp

Device:
No device...

Services:

Connections:
  • 以上で、remote.it CLIを使用するための準備が完了しました。 次に、remote,itにターゲットデバイスとサービスを登録していきます。

4. remote.it CLIを使用して、デバイスとサービスを登録する

デバイスの登録

  • デバイスをremote.itに登録します。デバイス名を登録できますので、任意の名前(今回はMyLinux)を入力してください。
$ sudo remoteit register
Device name: MyLinux
 ? REGISTER in progress ...
 ? Login with remote.it account
 ? Register device 'MyLinux'
 ? Applying config
 ? NEXT-ACTION: run 'remoteit add' to add services to this device
  • 登録したデバイスは、remoteit statusコマンドをjson(--json or -j)で表示させることにより確認することができます。
$ sudo remoteit status --json
{
  "device": {
    "name": "MyLinux",
    "id": "xx:xx:xx:xx:xx:xx:xx:xx",
    "type": "device",
    "state": "connected",
    "error": {
      "occur": false,
      "code": 0,
      "message": ""
    },
    "address": "127.0.0.1:65535",
    "startedAt": " 2021-02-15T06:51:53Z",
    "pid": "2864"
  },
  "services": [],
  "username": "xxxxxxxx@stylez.co.jp",
  "connections": []
}

サービス(接続先)の登録(ローカルデバイス)

  • remote.itでは、デバイスに対してアクセスさせたい通信(特定ポート宛てのリモート接続)をサービスとして登録します。まずは、このデバイス(MyLinux)宛てのSSH(TCP/22)を登録してみます。サービス名を登録できますので、任意の名前(今回はSSH)を入力してください。 ※希望のサービスタイプがメニューに無い場合には、tcpを選択してください
$ sudo remoteit add

Service Type is not specified or invalid. This is a list of valid service types

 ID      | Name          | Default Port   | Protocol   | Description
-------------------------------------------------------------------------------------
 1       | TCP           | 0              | TCP        | Generic TCP
 4       | VNC           | 5900           | TCP        | VNC remote desktop
 5       | RDP           | 3389           | TCP        | Microsoft remote desktop
 7       | HTTP          | 80             | TCP        | Web protocol
 8       | HTTPS         | 443            | TCP        | Secure web protocol
 28      | SSH           | 22             | TCP        | Secure shell terminal
 34      | SMB/CIFS      | 445            | TCP        | Internet file sharing
 37      | NxWitness     | 7001           | TCP        | Nx Witness VMS
 38      | Nextcloud     | 443            | TCP        | Nextcloud hub
 39      | OpenVPN       | 1194           | TCP        | OpenVPN server
 41      | Minecraft     | 25565          | TCP        | Minecraft server
 42      | Admin Panel   | 29999          | TCP        | remote.it admin panel
 32769   | UDP           | 0              | UDP        | Generic UDP
 32770   | WireGuard     | 51820          | UDP        | WireGuard VPN server

Enter Service Type ('ID' or 'Name', not case sensitive, default is 'ssh'): ssh
Enter Port (default is '22'): 22
Enter Service Name (default is 'MyService'): SSH ? ADD in progress ...
 ? Login with remote.it account
 ? Creating 'SSH' service named 'SSH' at '127.0.0.1:22'
 ? NEXT-ACTION: run 'remoteit add' to add more services
  • 登録したサービスは、remoteit statusコマンドをjson(--json or -j)で表示させることにより確認することができます。
$ sudo remoteit status --json
{
  "device": {
    "name": "MyLinux",
    "id": "xx:xx:xx:xx:xx:xx:xx:xx",
    "type": "device",
    "state": "connected",
    "error": {
      "occur": false,
      "code": 0,
      "message": ""
    },
    "address": "127.0.0.1:65535",
    "startedAt": "2021-02-15T06:51:53Z",
    "pid": "2864"
  },
  "services": [
    {
      "name": "SSH",
      "id": "xx:xx:xx:xx:xx:xx:xx:xx",
    "type": "SSH (28)",
      "state": " connected",
      "error": {
        "occur": false,
        "code": 0,
        "message": ""
      },
      "address": "127.0.0.1:22",
      "startedAt": "2020-10-13T04:43:31Z",
      "pid": "3077",
      "disabled": false
      "reachable": true
    }
  ],
  "username": "xxxxxxxx@stylez.co.jp",
  "connections": []
}

サービス(接続先)の登録(リモートデバイス)

  • remote.itのサービスはターゲットデバイス宛ての通信の他に、ターゲットデバイスを経由してそのデバイスに繋がれたネットワーク上にある、他のホスト宛ての通信(特定ポート宛てのリモート接続)を登録することができます。

  • つぎに、リモートホスト宛てのSSH(TCP/22)を登録してみます。リモートホスト宛てにサービスを登録する場合には、remoteit addコマンドに--hostname [hostname/ipaddress]オプションで、リモートホストを指定してください。サービス名を登録できますので、先程とは異なる任意の名前(今回はRemoteHost1-SSH)を入力してください。
    ※希望のサービスタイプがメニューに無い場合には、tcpを選択してください

$ sudo remoteit add --hostname 10.0.2.142

Service Type is not specified or invalid. This is a list of valid service types

 ID      | Name          | Default Port   | Protocol   | Description
-------------------------------------------------------------------------------------
 1       | TCP           | 0              | TCP        | Generic TCP
 4       | VNC           | 5900           | TCP        | VNC remote desktop
 5       | RDP           | 3389           | TCP        | Microsoft remote desktop
 7       | HTTP          | 80             | TCP        | Web protocol
 8       | HTTPS         | 443            | TCP        | Secure web protocol
 28      | SSH           | 22             | TCP        | Secure shell terminal
 34      | SMB/CIFS      | 445            | TCP        | Internet file sharing
 37      | NxWitness     | 7001           | TCP        | Nx Witness VMS
 38      | Nextcloud     | 443            | TCP        | Nextcloud hub
 39      | OpenVPN       | 1194           | TCP        | OpenVPN server
 41      | Minecraft     | 25565          | TCP        | Minecraft server
 42      | Admin Panel   | 29999          | TCP        | remote.it admin panel
 32769   | UDP           | 0              | UDP        | Generic UDP
 32770   | WireGuard     | 51820          | UDP        | WireGuard VPN server

Enter Service Type ('ID' or 'Name', not case sensitive, default is 'ssh'): ssh
Enter Port (default is '22'): 22
Enter Service Name (default is 'MyService'): RemoteHost1-SSH ? ADD in progress ...
 ? Login with remote.it account
 ? Creating 'SSH' service named 'RemoteHost1-SSH' at '10.0.2.142:22'
 ? NEXT-ACTION: run 'remoteit add' to add more services
  • 登録したサービスは、先程同様にremoteit statusコマンドをjson(--json or -j)で表示させることにより確認することができます。
$ sudo remoteit status --json
{
  "device": {
    "name": "MyLinux",
    "id": "xx:xx:xx:xx:xx:xx:xx:xx",
    "type": "device",
    "state": "connected",
    "error": {
      "occur": false,
      "code": 0,
      "message": ""
    },
    "address": "127.0.0.1:65535",
    "startedAt": "2021-02-15T06:51:53Z",
    "pid": "2864"
  },
  "services": [
    {
      "name": "SSH",
      "id": "xx:xx:xx:xx:xx:xx:xx:xx",
    "type": "SSH (28)",
      "state": " connected",
      "error": {
        "occur": false,
        "code": 0,
        "message": ""
      },
      "address": "127.0.0.1:22",
      "startedAt": "2020-10-13T04:43:31Z",
      "pid": "3077",
      "disabled": false
      "reachable": true
    }
  ],
    {
      "name": "RemoteHost1-SSH",
      "id": "xx:xx:xx:xx:xx:xx:xx:xx",
      "type": "SSH (28)",
      "state": "connected",
      "error": {
        "occur": false,
        "code": 0,
        "message": ""
      },
      "address": "10.0.2.142:22",
      "startedAt": "2021-02-15T08:59:36Z",
      "pid": "3191",
      "isDisabled": false,
      "isRetry": true,
      "isFailover": false,
      "isP2P": true,
      "reachable": true,
      "sessionID": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "initiatorUID": "xx:xx:xx:xx:xx:xx:xx:xx",
      "targetUID": "xx:xx:xx:xx:xx:xx:xx:xx"
    }
  "username": "xxxxxxxx@stylez.co.jp",
  "connections": []
}
  • 以上で、ターゲットデバイスとサービスの登録が完了しました。 次に、クライアントから登録されたターゲットとデバイスを確認して接続を行います。

5. remote.it CLIを使用して、他のremote.itデバイスへ接続する

  • 他のremote.itデバイスへの接続を、CLIで行ってみます。設定行うためには、接続先デバイスのサービスに割り当てされた「Service ID」が必要になります。

  • Service IDは、CLIの場合には接続先のデバイスで、目的の接続先サービスのUIDから確認することができます。
    ※接続先のデバイスで実行ください

$ sudo remoteit status
 ? Fetching status

Username: xxxxxxxx@stylez.co.jp

Device:
(中略)

Services:
 UID                        | Name                             | Type              | Status       | IP:Port                  | Enabled
-----------------------------------------------------------------------------------------------------------------------------------------
 xx:xx:xx:xx:xx:xx:xx:xx    | SSH                              |                   | connected    | 127.0.0.1:22             | true
(後略)
Connections:
  • remote.itのWEBポータルの場合には、接続先デバイスのサービス一覧から確認することができます。
    image.png

  • 接続先のService IDが分かった後に、CLIで接続を作成します。
    ※接続元のデバイスで実行ください

$ sudo remoteit connection add --id xx:xx:xx:xx:xx:xx:xx:xx
 ? ADD in progress ...
 ? Creating local connection
 ? NEXT-ACTION: run 'sudo remoteit status' for status
  • 作成した接続また、現在の接続状態はstatusで確認ができます。以下の例では、リモートホスト宛てのSSH接続が、ロカールホストのポート33001で接続中になっています。
$ sudo remoteit status
 ? Fetching status

Username: xxxxxxxx@stylez.co.jp

Device:

Services:

Connections:
 UID                        | Name                             | Type              | Status       | IP:Port                  | Enabled   | Retry   | P2P   | Failover
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
 xx:xx:xx:xx:xx:xx:xx:xx    | SSH                              | SSH (28)          | connected    | 127.0.0.1:33001          | true      | false   | true  | false
  • 少しわかりづらいですが、statusで表示されている項目の内容は以下の通りとなります。
項目 内容
UID 接続先のService ID
Name 接続先の名称
Type 接続先のサービスタイプ
※remoteit supportedApplicationsを参照
Status 接続状況(connecting/connected/offline)
IP:port 現在の接続がBINDされているIP:port(ローカルの接続先)
Enabled 接続先が有効か否か(trueで有効)
Retry 接続の再試行が有効か否か(trueで有効)
P2P 現在の接続が、P2Pで接続されているか否か(falseの場合Proxy)
Failover 現在の接続が、failoverされた接続か否か(trueの場合failover(P2P->Proxy)された接続)
  • connectionの主なオプション(connection --help)は次の通りです。接続作成(connection add)もしくは、接続の修正(connection modify)で設定ができますので、必要に応じて選択をしてください。
    ※現時点のバージョンでは各単独で設定変更できないかつ、指定しないものはDefault値に戻ってしまうので、必要なものを全て指定する必要があります
    ※add時にはDefault値があるが、modify時にはDefault値が設定されないものがあります(hostname, restrict, retry)
項目 内容
--id 接続先のService ID(入力必須)
--port ロカールホストのremote.it用の接続ポート番号(Default:自動割当)
--hostname LAN共有をする場合のBIND IP(Default:127.0.0.1)
--restrict LAN共有をする場合の接続IPの制限(許可IP、Default:0.0.0.0)
--p2p p2p接続をを使用するか否か(trueで使用、Default:true)
※falseの場合にはproxy接続(--failover trueが必要)
--failover connection filoverを使用するか否か(trueで使用、Default:true)
--retry 接続の再試行を行うか否か(trueで再試行あり、Default:false)
--servicetype 接続先のサービスタイプ(Default:自動検出)
※remoteit supportedApplicationsを参照
--log 接続の詳細ログを出力するか否か(trueで出力、Default:false)
※接続毎に別ファイルとして出力されます
--logfolder 接続ログ(詳細)を出力した場合の保存先フォルダ(Default:指定なし)
※logfolderを指定しない場合には、サービス実行ユーザのhome(~/)に出力されます(Default:/root)
  • 以下のオプションはconnection add時のみ指定できます。
項目 内容
--connect 自動的に接続を開始するか否か(trueで自動開始)
  • 以下のオプションはconnection modify時のみ指定できます。
項目 内容
--name 任意の接続名称(Default:指定なし)
--enable 接続の有効無効の切り替え(Default:指定なし)
※接続状態は remoteit status で確認(connecting/connected/offline)

6. remote.it CLI の使い方全般を学ぶ

CLIオプションの表示

remote.it CLIのその他のオプションは、remoteit --helpにて確認することができます。また、各コマンドの詳細オプションが知りたい場合には、各コマンドの最後に同様に--helpと入力してください。
image.png

CLI各オプションの概要

remoteit –helpで確認できる、各オプションの概要となります。

  • Account
項目 内容
remoteit siginin サインインしたremote.itアカウントを、このデバイスで使用します
remoteit signout このデバイスにサインインしているremote.itアカウントを、サインアウトします
  • Devices & Service
項目 内容
remoteit register このデバイスを、remote.itアカウントに登録します
※サインインしているアカウントに登録されます
※既に別のアカウントで登録済デバイスの場合には、そのアカウントでtransferを使用することができます
remoteit unregister このデバイスを、登録されたremote.itアカウントから削除します
※デバイスを登録したアカウントで実行ください
remoteit transfer このデバイスの登録を、他のremote.itアカウントへ移管します
※デバイスを登録したアカウントで実行ください
remoteit add このデバイスに、remote.itの接続先ポート(サービス)を登録します
※デバイスを登録したアカウントで実行ください
remoteit remove このデバイスから、登録されたremote.itの接続先ポート(サービス)を削除します
※デバイスを登録したアカウントで実行ください
remoteit modify このデバイスに登録されている、remote.itの接続先ポート(サービス)の内容を変更します
※デバイスを登録したアカウントで実行ください
  • Connection (connection)
項目 内容
remoteit connection add このデバイスから接続する、リモート接続先を登録します
※他のデバイスへのリモート接続の登録となります
remoteit connection remove 登録されているリモート接続先を削除します
remoteit connection modify 登録されているリモート接続先の内容を変更します
  • DevOps & Automation
項目 内容
remoteit tools remote.itの関連バイナリファイル等をインストールします
remoteit scan 同じネットワーク(subnet)で動作しているホストのサービスをスキャンします (port scan)
remoteit uninstall remote.itのすべての設定を削除し、remote.itバイナリを除くすべてのファイルを削除します
※signout, unregister, remove, connection remove, tools uninstall, agent uninstall
remoteit reset remote.itのすべての設定を削除します
※signout, unregister, remove, connection remove
remoteit enableDebug remote.itのデバッグログを有効/無効に設定します
※設定後に、remoteit agent restartが必要です
  • remote.it Agent (agent/system)
項目 内容
remoteit agent install remote.it をシステムサービスに登録します (systemd)
remoteit agent uninstall remote.it をシステムサービスから削除します (systemd)
remoteit agent start remote.it サービスを開始します (systemctl start)
remoteit agent stop remote.it サービスを終了します (systemctl stop)
remoteit agent restart remote.it サービスを再起動します (systemctl restart)
  • Misc
項目 内容
remoteit status remote.itの設定とステータスを表示します
remoteit version remote.itのagent/CLIのバージョンを表示します
remoteit info remote.itの環境情報を表示します
remoteit support remote.itへのサポートチケット(問合せ)を発行します<BR※詳細動作未確認となります
remoteit supportedApplications remote.itに登録されているアプリケーションの一覧を表示ます
※登録されていないアプリケーションでも、TCP/UDPを使用することで、任意のポートへのリモート接続が設定できます

CLI使用時のTips

remote.it CLIの使い方の例をいくつか紹介します。下記では紹介していませんが、必要なパラメータをワンライナーで入力することもできます。詳細オプションについては、各コマンドの--helpを参照してください。

  • remtoe.it CLIを新規にインストールする(linux_x86_64の場合)
$ curl -LkO https://downloads.remote.it/cli/latest/remoteit_linux_x86_64
$ sudo cp remoteit_linux_x86_64 /usr/bin/remoteit
$ sudo chmod +x /usr/bin/remoteit
$ sudo remoteit agent instll
$ sudo remoteit tools install
  • remtoe.it CLIをアップデートする(linux_x86_64の場合)
$ curl -LkO https://downloads.remote.it/cli/latest/remoteit_linux_x86_64
$ sudo cp remoteit_linux_x86_64 /usr/bin/remoteit
$ sudo remoteit tools install --yes
$ sudo remoteit agent restart
  • remtoe.itアカウントでサインインする
$ sudo remoteit signin
※remote.itアカウントが必要(https://app.remote.it/auth/#/sign-up)
  • remtoe.itアカウントにデバイスを登録する
$ sudo remoteit register
※remoteit signinが必要(siginしているremtoe.itアカウントに登録されます)
  • デバイスにサービス(接続先)を登録する(ローカルデバイス) ※このホスト宛
$ sudo remoteit add
※remoteit registerが必要(registerしているデバイスに登録されます)
  • デバイスにサービス(接続先)を登録する(リモートデバイス) ※リモートホスト宛
$ sudo remoteit add --hostname HOSTNAME
HOSTNAME: LAN内のリモートホストのホスト名またはIPアドレス
※remoteit registerが必要(registerしているデバイスに登録されます)
  • リモート接続先を登録する(LAN共有無し)
$ sudo remoteit connection add –id UID
UID: 接続先サービスのServiceID
  • リモート接続先を登録する(LAN共有あり)
$ sudo remoteit connection add –id UID --hostname LocalHostIP –restrict RestrictIP
UID: 接続先サービスのServiceID
LocalHostIP: この接続のLAN共有のために使用する、ロカールホストのIP
RestrictIP: この接続のLAN共有に接続できるホストのIP

■remtoe.itのステータスを確認する

$ sudo remoteit status
$ sudo remoteit status --json

■remtoe.itのコンフィグを確認する

$ sudo cat /etc/remoteit/config.json

■remtoe.it agentの動作状況を確認する

$ sudo remoteit agent status
$ sudo remoteit agent status --verbose
$ sudo journalctl -u it.remote.cli
$ sudo tail /var/log/remoteit/remoteit.log
11
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
2