LoginSignup
1
0

More than 5 years have passed since last update.

Githubの公開鍵でサーバへログイン出来るようにするシェル

Posted at

新しくエンジニアが入ったときにサーバへのログインしてもらうときによくやるやつメモ。

createUser.sh
#!/bin/bash

if [ ! $1 ]; then
  echo "pass the username to create."
  exit 1;
fi

useradd $1;

cd /home/$1

mkdir /home/$1/.ssh

chmod 700 /home/$1/.ssh

curl https://github.com/$1.keys >> /home/$1/.ssh/authorized_keys

chmod 600 /home/$1/.ssh/authorized_keys

chown -R $1:$1 /home/$1/

echo "$1 user created"

Usage

$ sh createUser.sh ichiwa
1
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
1
0