Skip to content

Instantly share code, notes, and snippets.

@miminashi
Last active December 23, 2023 19:51
Show Gist options
  • Save miminashi/7a7d6896419b2c4a79d6ff6a29454770 to your computer and use it in GitHub Desktop.
Save miminashi/7a7d6896419b2c4a79d6ff6a29454770 to your computer and use it in GitHub Desktop.
Debian12 をインストールしたサーバのコンソールでdebianユーザがsshログインして使用するための初期セットアップをおこなう
#!/bin/sh
#
# Copyright (c) 2023 Shiro Miminashi Nohara
# Released under the MIT license
# https://opensource.org/licenses/mit-license.php
#
# USAGE 使い方:
# $ wget -q -O - https://gist.githubusercontent.com/miminashi/7a7d6896419b2c4a79d6ff6a29454770/raw | sh -s
# # rootで実行する場合
# $ wget -q -O - https://tiny.cc/w7gfvz | sh -s
# # 一般ユーザで実行する場合
# $ su -c 'wget -q -O - https://tiny.cc/w7gfvz | sh -s'
github_username="miminashi"
username="debian"
set -eu
# ssh
mkdir -p /home/${username}/.ssh
wget -O - https://github.com/${github_username}.keys > /home/${username}/.ssh/authorized_keys
chown -R "${username}" /home/${username}/.ssh
chgrp -R "${username}" /home/${username}/.ssh
chmod 600 /home/${username}/.ssh/authorized_keys
apt-get update
# sudo
apt-get -y install sudo
#/sbin/usermod -aG sudo ${username}
gpasswd -a ${username} sudo
# GNU screen
apt-get -y install screen
cat > /home/${username}/.screenrc <<'EOF'
startup_message off
vbell off
caption always " %n %t $USER@%H"
termcapinfo xterm* ti@:te@
term xterm-color
shell bash
EOF
chown "${username}" /home/${username}/.screenrc
chgrp "${username}" /home/${username}/.screenrc
# POSIX compatibility
# POSIX互換性のための設定
apt-get -y install bc pax ncompress
# other utility
# その他のユーティリティ
apt-get -y install vim curl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment