0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Vultr APIでSSHの公開鍵を登録する

Posted at

前回の記事ではファイアウォールのグループとグループに紐づくルールを作成したので、今回はVultr APIを使ってSSHの公開鍵を登録してみます。


「Vultr API」のドキュメントで「SSH Keys」の「Create SSH key」を参照すると、「/v2/ssh-keys」で公開鍵の登録ができるようです。

image.png


発行済のAPIキーを環境変数「VULTR_API_KEY」に格納します。

$ export VULTR_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

ドキュメント内の「Copy」ボタンをクリックしてターミナルに貼り付けて、 jq コマンドで整形するようにして実行します。

$ curl "https://api.vultr.com/v2/ssh-keys" \
  -s \
  -X POST \
  -H "Authorization: Bearer ${VULTR_API_KEY}" \
  -H "Content-Type: application/json" \
  --data '{
    "name" : "My First SSH Key",
    "ssh_key" : "ssh-ed25519 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX xxxxxxxx@xxxxx.xxx"
  }' | jq .
{
  "ssh_key": {
    "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    "date_created": "2025-08-05T23:07:18+00:00",
    "name": "My First SSH Key",
    "ssh_key": "ssh-ed25519 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX xxxxxxxx@xxxxx.xxx"
  }
}

Vultrのページにログインした状態で、左側のメニューから「Account」>「OTHER」>「SSH Keys」をクリックします。

image.png


「SSH Keys」の画面に先ほど登録した「My First SSH Key」が表示されています。

image.png

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?