「モバイルシェル」とも呼ばれるMoshは、リモートLinuxサーバーを接続するために使用されるコマンドラインツールです。 Moshはモバイル作業用に最適化されています。ローミングを可能にし、断続的な接続をサポートし、ユーザーのキーストロークのインテリジェントなローカルエコーとライン編集を提供します。 MoshはSSHの代替手段であり、SecureShellよりも多くの機能を提供します。 Linux、FreeBSD、Solaris、Mac OS X、Androidを含むすべての主要なオペレーティングシステムで利用できます。
この投稿では、LinuxにMoshコマンドラインツールをインストールして使用する方法を紹介します。
前提条件
- Atlantic.Netクラウドプラットフォーム上の新しいUbuntu/CentOSサーバー
- サーバーで構成されているrootパスワード
Atlantic.Netクラウドサーバーを作成する
まず、Atlantic.Netクラウドサーバーにログインします。 2GB以上のRAMを搭載したオペレーティングシステムとしてUbuntu/CentOSを選択して、新しいサーバーを作成します。 SSH経由でクラウドサーバーに接続し、ページの上部で強調表示されているクレデンシャルを使用してログインします。
Ubuntu / CentOSサーバーにログインしたら、次のコマンドを実行して、ベースシステムを最新の利用可能なパッケージで更新します。
apt-get update -y
または
yum update -y
Moshのインストール
DebianベースのLinuxディストリビューションの場合、次のコマンドを使用してMoshをインストールできます。
apt-get install mosh
CentOSベースのLinuxディストリビューションの場合、次のコマンドを使用してMoshをインストールできます。
yum install mosh
Moshがインストールされたら、次のコマンドを使用して、インストールされているMoshのバージョンを確認できます。
mosh --version
次の出力が得られるはずです:
mosh 1.3.2 [build mosh 1.3.2] Copyright 2012 Keith Winstein <example@unixlinux.online> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
次のコマンドを使用して、Moshで使用可能なすべてのオプションを表示することもできます。
mosh --help
次の出力が得られるはずです:
Usage: /usr/bin/mosh [options] [--] [example@unixlinux.online]host [command...]
--client=PATH mosh client on local machine
(default: "mosh-client")
--server=COMMAND mosh server on remote machine
(default: "mosh-server")
--predict=adaptive local echo for slower links [default]
-a --predict=always use local echo even on fast links
-n --predict=never never use local echo
--predict=experimental aggressively echo even when incorrect
-4 --family=inet use IPv4 only
-6 --family=inet6 use IPv6 only
--family=auto autodetect network type for single-family hosts only
--family=all try all network types
--family=prefer-inet use all network types, but try IPv4 first [default]
--family=prefer-inet6 use all network types, but try IPv6 first
-p PORT[:PORT2]
--port=PORT[:PORT2] server-side UDP port or range
(No effect on server-side SSH port)
--bind-server={ssh|any|IP} ask the server to reply from an IP address
(default: "ssh")
--ssh=COMMAND ssh command to run when setting up session
(example: "ssh -p 2222")
(default: "ssh")
--no-ssh-pty do not allocate a pseudo tty on ssh connection
--no-init do not send terminal initialization string
--local run mosh-server locally without using ssh
--experimental-remote-ip=(local|remote|proxy) select the method for
discovering the remote IP address to use for mosh
(default: "proxy")
--help this message
--version version and copyright information
Moshの操作
Moshは、同じSSH方式を使用してリモートサーバーに接続します。次のコマンドを実行して、リモートサーバーに接続します。
mosh example@unixlinux.online
リモートサーバーに接続するためのrootパスワードの入力を求められます。
リモートSSHサーバーがポート2200でリッスンしている場合は、次のコマンドを使用して指定できます。
mosh --ssh="ssh -p 2200" example@unixlinux.online
Moshの最も優れた機能の1つは、ネットワーク接続が失われた場合に通知を送信することです。ネットワーク接続が復元されると、サーバーに同期され、リモートサーバーに自動的に接続されるため、Moshウィンドウを閉じる必要はありません。
結論
上記の投稿では、Atlantic.NetからLinuxVPSにMoshコマンドラインツールをインストールして使用する方法を学びました。 SSHと比較して優れたツールです。一般的に、Moshは低速のネットワーク接続で使用されます。詳細については、Moshのドキュメントページにアクセスしてください。