CORESERVERにSSHでログイン

サーバ登録してから、SSHでログインするまでの手順の覚え書き。

サーバ登録の方法は、CORESERVERのご利用手順のとおり。以下の例では、ここで登録した「アカウント名」(このサイトの場合、firewheel)および「サーバ名」(同、m40.coreserver.jp)を使用しているので、各自の環境に合わせて適宜変更のこと。

ローカルでのSSH鍵生成は、例えば記載時点での最新のCygwin環境下(openssh-6.6p1)では以下のとおりであった。

$ ssh-keygen -t rsa -b 2048 -C firewheel@m40.coreserver.jp
Generating public/private rsa key pair.
Enter file in which to save the key (/home/firewheel/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/firewheel/.ssh/id_rsa.
Your public key has been saved in /home/firewheel/.ssh/id_rsa.pub.
The key fingerprint is:
d8:5e:d8:38:20:20:ac:9d:72:55:21:1b:94:ef:ab:85
firewheel@m40.coreserver.jp The key's randomart image is:
+--[ RSA 2048]----+
|o ..+oo.         |
| o .o+           |
|.. oo..          |
|o +  ..+ +       |
| o   .. S o      |
|     ... o       |
|    E ...        |
|     ..          |
|    ..           |
+-----------------+

通常であればリモートサーバに公開鍵を転送しておしまい、であるが・・・

$ ssh-copy-id -i ~/.ssh/id_rsa.pub firewheel@m40.coreserver.jp
The authenticity of host 'm40.coreserver.jp (202.172.26.41)' can't be established.
RSA key fingerprint is c4:f5:91:b3:c1:25:84:d8:ea:08:fb:46:a9:a5:fe:4f.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys firewheel@m40.coreserver.jp's password:
rbash: line 2: .ssh/authorized_keys: restricted: cannot redirect output

残念、CORESERVERからメールで送られてくるパスワードでログインしてデフォルトシェルを変更する。

$ ssh firewheel@m40.coreserver.jp
firewheel@m40.coreserver.jp's password:

firewheel@m40:~> chsh
Changing login shell for firewheel.
Password:
Enter the new value, or press return for the default.
        Login Shell [/bin/rbash]: /bin/bash
Shell changed.
firewheel@m40:~> exit
logout
Connection to m40.coreserver.jp closed.

あらためてリモートサーバに公開鍵を転送し、鍵認証でログインする。

$ ssh-copy-id -i .ssh/id_rsa.pub firewheel@m40.coreserver.jp
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
firewheel@m40.coreserver.jp's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'firewheel@m40.coreserver.jp'"
and check to make sure that only the key(s) you wanted were added.
$ ssh firewheel@m40.coreserver.jp
Enter passphrase for key '/home/firewheel/.ssh/id_rsa':
Last login:**********

firewheel@m40:>

今日はここまで。まだWordPressになじめず、結局HTMLタグも手書きしてしまった。

コメント

タイトルとURLをコピーしました