LoginSignup
70
73

More than 5 years have passed since last update.

Linuxユーザーの追加〜SSH公開鍵登録まで

Posted at

Linuxユーザーの追加〜SSH公開鍵登録まで

1.rootになる。

su

2.ユーザーを追加する。

useradd soushi
passwd soushi
su soushi

3 公開鍵を、ユーザーのホームフォルダ配下~/.ssh/authorized_keysファイルへ追加。

3.1 authorized_keysファイルを作成し、開きます。
3.2 公開鍵(id_rsa.pubの中身)をペーストします。
cd
mkdir .ssh
chmod 700 .ssh
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
vi ~/.ssh/authorized_keys
  • 新しくログインIDを使う人(ここではsoushi)に、自分のパソコン上で ssh-keygen コマンドを使い、 秘密鍵(=id_rsa) と、 公開鍵(=id_rsa.pub) を作成して貰います。
  • id_rsa.pubを メモ帳等で開き 、中身をauthorized_keysファイルにペーストします。

soushiのid_rsa.pub

4.1 ユーザーsoushiをsudoersに追加する。

sudoコマンドを実行するために必要

※テキストファイルを直接編集するのではなく、必ずvisudoコマンドを用いること。(構文チェックが行われる)

su
visudo

開いたテキストファイルの、rootの下に、以下のように追加
※ユーザーsoushiに、全ての実行権限を与えるという意味

## Allow root to run any commands anywhere
root ALL=(ALL) ALL
soushi ALL=(ALL) ALL
70
73
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
70
73