SSH
#SSL/TLS #OpenSSH
config manual
https://linux.die.net/man/5/ssh_config
SSH接続用のアカウント設定
不正アクセスを回避しながら SSH を使用して安全に EC2 Linux インスタンスにアクセスするためのベストプラクティスは何ですか?
https://repost.aws/ja/knowledge-center/ec2-ssh-best-practices
AWS System Manager Session Manager を使用する
root ユーザーに SSH ターミナルの使用を許可しない
sshd_configの設定
以下に設定する。初期は
code:/etc/ssh/sshd_config
PermitRootLogin no
PasswordAuthentication no
AWS公式イメージ(Ubuntu)の場合
PasswordAuthenticationは、無効化されている
less sshd_config.d/60-cloudimg-settings.conf
EC2 インスタンスを保護するためのヒント
https://aws.amazon.com/jp/articles/tips-for-securing-your-ec2-instance/
Session Managerなどを使用してSSHポートを開けない。
セキュリティグループをEC2ごとにすれば、影響しなさそう。
ubuntuにSSHアカウント追加
Amazon EC2 Linux インスタンスのシステムユーザーを管理する
https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/managing-users.html
デフォルトでは、パスワード認証とルートログインは無効になっており、また、sudo は有効化されています。
ローカルで、キーを予め作成しておく
ssh-keygen -t rsa -b 4096
サーバー側で作業
sudo adduser newuser
sudo usermod -aG sudo newuser
sudo su - newuser
code:sh
mkdir .ssh
chmod 700 .ssh
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
vim .ssh/authorized_keys
デフォルトユーザーのロック
sudo passwd -l ubuntu
-----------------------------
多段ssh
https://dev.classmethod.jp/articles/direct-ssh-by-proxycommand/
ホスト認証
ユーザー認証
https://www.omoikane.co.jp/man30/w_ssh.html
useradd
Linux コマンドメモ
passwd
sudoユーザーを追加する方法 - Linux入門 - Webkaru
usermod -aG wheel ユーザー名
sudoユーザーの設定
arch linux wiki  ssh設定
https://wiki.archlinux.jp/index.php/SSH_鍵
code:ssh
chmod 700 .ssh
ssh-keygen -t rsa -b 4096
mv ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
chmod 400 ~/.ssh/authorized_keys
----------------------------------
code:ssh command
ssh ec2-user@10.0.1.196 -i id_rsa
scp -i id_rsa file.txt ec2-user@10.0.1.196:
設定
code:sshd_config
#特定のユーザーだけパスワード認証許可できるみたい。
Match User sftp-*
ChrootDirectory /home/sftp-only/ #このディレクトリのみアクセスできる設定みたい。
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp #特定のユーザーだけsftpだけにできるみたい
PasswordAuthentication yes
windows
git bash
ssh-agent
ssh-agent起動して、秘密鍵をaddする
eval ssh-agent
ssh-agent起動
ssh-add 秘密鍵
ssh-add -l
登録されている鍵のFingerprints一覧を表示