複数VMアクセス
xpanes -c "ssh cdsl@{}" ~
ファイルシステムのチェック
sudo fsck
STNSサーバのインストール¶
STNSを入れる準備(curlを入れる)
sudo apt update
sudo apt install curl
STNSを入れる
curl -fsSL https://repo.stns.jp/scripts/apt-repo.sh | sh
sudo apt install stns-v2 libnss-stns-v2
/shareの権限を変更
sudo chmod 755 /share
/share/stnsにディレクトリを作成
sudo mkdir /share/stns
mkdir: cannot create directory ‘stns’: File exists
cpで/etc/stns/server/stns.confを/share/stnsにコピー
sudo cp /etc/stns/server/stns.conf /share/stns
sudo cp stns.conf stns.conf.org
コピー終わったので/etc/stns/server内のファイルを削除
sudo rm stns.conf stns.conf.org
/etc/stns/serverにシンボリックリンクを張り/share/stnsに飛ぶように
sudo ln -s /share/stns/stns.conf /etc/stns/server/
/etc/stns/server内で ls -laした結果
lrwxrwxrwx 1 root root 21 Jul 15 14:03 stns.conf -> /share/stns/stns.conf
sudo systectl restart stns
/share/stnsのstns.confの書き換え
[users.c0117039]
id = 2001
group_id = 2201
keys = ["ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxstSNccyAwOirnuN2OiLhR/x/Rx7AL0J+soIgOiPo1Iy/2TlEQUDo56jLRg3SDFiG+/gtknQIqqsbqB3rIktYw3wZrKcOBeazITirST36sW239z+qs3dT/WxB4/QxVaHq7u9rBq2vch8+UMKe3KFXTVyxBLffbdpnuRcwvGctHsvUmLs6wnio/axlUXiZ8+LuSnOJJUkCQon6DMgRvyFT/B5KLQQU9ac3I5RxxUHvtbmZNFFphyZ5Loi49MgjnoivohgRyKk3B6X9up+PgQVeGs4B+BhXGi0fz/50ZgoYcr3fLCNFlgulNWPHHQAX4rIAepuzJYJx99jcIC1Wqol3Q== Admin@LAPTOP-JPMF9LFN"]
keysは踏み台サーバーの.ssh/authorized_keys
[groups.cdsl]
id = 2201
users = ["c0117039"]
stns.conf (END)#module_path = "/usr/local/stns/modules.d"
#load_module = "mod_stns_etcd.so"
port = 1104
stnsが再起動&起動できているかを確認
sudo systemctl restart stns
sudo systemctl status stns
curl http://localhost:1104
STNSクライアントのインストール¶
STNSを入れる準備(curlを入れる)
sudo apt update
sudo apt install curl
STNSを入れる
curl -fsSL https://repo.stns.jp/scripts/apt-repo.sh | sh
sudo apt install libnss-stns-v2 cache-stnsd
/etc/stns/client/stns.confの設定を変更
api_endpoint = "http://192.168.100.13:1104/v1"
/etc/nsswitch.confを書き換え
passwd: compat systemd stns
group: compat systemd stns
shadow: compat stns
systemd-logindがネットワークアクセスを許可しない設定の場合、HTTPリクエストができないため、必要に応じて許可
sudo sed -i "s/^IPAddressDeny=any/#IPAddressDeny=any/" /lib/systemd/system/s
ystemd-logind.service
sudo systemctl daemon-reload
sudo systemctl restart systemd-logind
/etc/ssh/sshd_configをバックアップ&書き換え(コメントアウトを外す)
cp sshd_config sshd_config.org
/etc/ssh/sshd_config
PubkeyAuthentication yes
AuthorizedKeysCommand /usr/lib/stns/stns-key-wrapper
AuthorizedKeysCommandUser root
設定後sshdを再起動
## SSH KeyAgentnの設定
https://qiita.com/shotaTsuge/items/9f337bad9f73c3953af1
ローカルのssh鍵を踏み台に自動複製する設定
windowsコマンドプロンプトで
- sc config ssh-agent start=auto
[SC] ChangeServiceConfig SUCCESS
- sc start ssh-agent
powershellで確認 - ssh-add -l The agent has no identities. - ssh-add -k Identity added: C:\Users\c011703961/.ssh/id_rsa (Admin@LAPTOP-JPMF9LFN)
踏み台サーバにアクセス後にも確認 - ssh-add -l 2048 SHA256:J0cU04cAsWfYxI2eUCjoBRYAZM+mLvjSLXandnbptng Admin@LAPTOP-JPMF9LFN (RSA)
エージェントにログインできるか確認 - ssh 192.168.100.178