2012年3月8日木曜日

UbuntuのPuttyで日本語を入力する方法

UbuntuのソフトウェアセンターからPuttyをインストールして楽ちんだな~と思いながら使っていると、問題が・・・
まず、日本語入力ができない!これは大問題です。次に、WindowsのPuttyだと出来ていたドラッグした部分が自動的にコピーされて、右クリックでペースト。これもできませんでした。
設定か?それともそういうものなのか?と思って色々調べていましたがPuttyだけで解決する方法が見つかりませんでした。

そこで、Puttyをインストールしたら一緒に付いてくるplinkというputtyのコマンドラインツールを試してみると無事日本語入力が出きるようになりました。
plinkとは、ターミナルから直接Puttyを利用するためのコマンドラインツールです。
そのため、Puttyのウインドウではなくて、標準のターミナルでリモートに接続できます。
なので、文字列のコピーは標準のターミナルと同じ手順になります。

では、実際にどうやって使うかというと、基本はplinkに接続先ホスト名やユーザ名等を指定して実行する形になります。

plink [ユーザ名]@[ホスト] -P [ポート番号] -i [SSHの秘密鍵(必要なら)]

・・・日本語が入力出来るようになるのはうれしいけど毎回接続情報入力するのは面倒くさい・・・
しかしさすがPutty専用のコマンドラインツール!
loadオプションに、Puttyに保存されているセッション名を渡してあげると、その情報を使ってリモートに接続する事が出来ます。
しかもセッション名に日本語を使っていても問題ありませんでした。

例えば、「開発マシーン!」というセッション名でリモートサーバ情報を保存している場合、plinkを以下のように実行します。

plink -load 開発マシーン!

これだけで、Puttyで接続した時とまったく同じ情報でリモートに接続できます。

ただし、plinkだとPuttyのように接続先によって背景色を変えるなどが出来ないようです。
この部分だけ不満ですが実用上問題ないのでま、いっか~という状況です。

実際にログインした際には以下のようになります。

k-kuwana@VirtualBox:~$ plink -load "[セッション名]"
Using username "[接続するユーザ名]".
Passphrase for key "[鍵名]": //鍵を使用していたらその鍵名が表示されて、パスフレーズの入力が求められます
Last login: Wed Mar  7 14:56:08 2012 from xxx.xxx.xxx.xxx
[接続ユーザ名@接続ホスト名 ~]$

今後は、Putty Configuration(Puttyを起動したら表示される画面)で、サーバ情報だけ保存して、実際の接続はすべてplinkで行おうと思っています。

plinkのヘルプは以下の通りです。
k-kuwana@VirtualBox:~$ plink
PuTTY Link: command-line connection utility
Release 0.61
Usage: plink [options] [user@]host [command]
       ("host" can also be a PuTTY saved session name)
Options:
  -V        print version information and exit
  -pgpfp    print PGP key fingerprints and exit
  -v        show verbose messages
  -load sessname  Load settings from saved session
  -ssh -telnet -rlogin -raw -serial
            force use of a particular protocol
  -P port   connect to specified port
  -l user   connect with specified username
  -batch    disable all interactive prompts
The following options only apply to SSH connections:
  -pw passw login with specified password
  -D [listen-IP:]listen-port
            Dynamic SOCKS-based port forwarding
  -L [listen-IP:]listen-port:host:port
            Forward local port to remote address
  -R [listen-IP:]listen-port:host:port
            Forward remote port to local address
  -X -x     enable / disable X11 forwarding
  -A -a     enable / disable agent forwarding
  -t -T     enable / disable pty allocation
  -1 -2     force use of particular protocol version
  -4 -6     force use of IPv4 or IPv6
  -C        enable compression
  -i key    private key file for authentication
  -noagent  disable use of Pageant
  -agent    enable use of Pageant
  -m file   read remote command(s) from file
  -s        remote command is an SSH subsystem (SSH-2 only)
  -N        don't start a shell/command (SSH-2 only)
  -nc host:port
            open tunnel in place of session (SSH-2 only)
  -sercfg configuration-string (e.g. 19200,8,n,1,X)
            Specify the serial configuration (serial only)

0 件のコメント: