LoginSignup
33
31

More than 5 years have passed since last update.

さくらVPSに複数のMacからSSH接続(2台目以降)

Last updated at Posted at 2013-08-22

SSHキーの作成

% cd ~/.ssh
% mkdir sakura_vps
% cd sakura_vps
% ssh-keygen -t rsa -C "任意のコメント" //コメントはなんでもいいらしいです

//セキュリティ強化
% chmod 600 作成した秘密鍵

Rootとパスワードでのログインを許可する(VPS側)

/etc/ssh/sshd_configを以下のように編集

// パスワードログインを許可
PasswordAuthentication yes

// rootログインを許可
PermitRootLogin yes
// sshdリスタート
% service sshd restart

公開鍵をさくらVPSに送信(Mac側)

scpで公開鍵を送信

% sudo scp -P sshのポート番号 ~/.ssh/sakura_vps/公開鍵 root@xxx.xxx.xxx.xxx:/home/USERNAME

sshdの再設定と公開鍵の追加(VPS側)

先ほど編集した/etc/ssh/sshd_configを以下のように再編集

// パスワードログインを禁止
PasswordAuthentication no

// rootログインを禁止
PermitRootLogin no
// sshdリスタート
% service sshd restart

先ほど送信した公開鍵を~/.ssh/authorized_keysに追記

cat 送信した公開鍵 >> .ssh/authorized_keys 

ホスト名を設定

~/.ssh/configに以下の内容を追加

~/.ssh/config
HOST sakura_vps
    HostName      xxx.xxx.xxx.xxx
    Port          SSHのポート番号
    User          ユーザ名
    identityfile  ~/.ssh/sakura_vps/秘密鍵

以上の設定で

% ssh sakura_vps

で、ログインできます。

参照

03.さくらインターネットVPSを使ってみる。〜複数のMacからssh接続〜

33
31
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
33
31