1. パブリックキーをサーバーの任意のフォルダへコピー
2. サーバーにコピーされたキーをauthorized_keysへ追記
3. 元のパブリックキーを消去
(サーバーに~/.sshフォルダやauthorized_keysがない場合は下記を参照)
1. パブリックキーをサーバーの任意のフォルダへコピー
構文
scp (ローカルのパブリックキー) (ユーザー名)@(IP アドレス):(パブリックキーを移動させたいフォルダ)
scp ~/.ssh/id_rsa.pub user@remote.server.com:/home/username
2. サーバーにコピーされたキーをauthorized_keysへ追記
cat /home/username/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys3. 元のパブリックキーを消去
rm /home/username/.ssh/id_rsa.pubもしサーバーに~/.sshフォルダやauthorized_keysが見当たらない場合
1. SSHでログインする2. ~/.sshフォルダを作る
3. authorized_keysファイルを作る
1. SSHでログインする
ssh username@ipaddress2. ~/.sshフォルダを作る
mkdir ~/.ssh/home/username/.sshフォルダが作成される
3. authorized_keysファイルを作る
touch authorized_keysこれで空のauthorized_keysファイルが出来る