0
0

More than 3 years have passed since last update.

sshユーザー追加 -- raspi

Posted at

目的

raspiに秘密鍵でssh接続できている環境で、新たなユーザーにsshの権限を与えたいときの手順。
そもそもの設定を知りたい場合はこちら

目次

1.ユーザーの作成
2.sshの設定

内容

1.ユーザーの追加

まずは、raspiに新たなユーザーを作る。


# 'まずはrootユーザーになる'
 su -
# 'adduser [ユーザー名で作成]'
 adduser newuser
# 'なんか色々聞かれるがpassword以外は空白のままでOK'
# '作成できたらsudo権限を付与する(これは必要なければスキップ)'
 gpasswd -a newuser sudo

これで作成は完了。

2.sshの設定

作成したユーザーとしてログインし、秘密鍵でアクセスするための設定を行う。


# '作成したユーザーとしてログイン'
 su - testuser
# 'ホームディレクトリに.sshディレクトリを作成'
 mkdir .ssh
# 'パーミッションの変更'
 sudo chmod 700 .ssh
# 'authorized_keysの作成(もしくは作成した公開鍵のファイル名を変更してください)'
# 'ここでは省略しますが、作成後公開鍵の内容を貼り付けます'
 touch authorized_keys
# 'パーミッションの変更'
 sudo chmod 600 authorized_keys

あとは、外からアクセスできれば完了!

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