LoginSignup
2
3

More than 5 years have passed since last update.

対話的シェルをexpectを使って自動化する

Posted at

概要

expect を使う機会があったので作ったシェルを残しておく

jenkinsユーザのbash設定

ユーザを作成しただけだと、/bin/falseとなっているのでbashを有効にしてあげる

#!/bin/bash
expect -c "
spawn chsh jenkins
expect \"New shell\"
send \"\/bin\/bash\\n\"
interact
"

パスワードなしsshキー作成

#!/bin/bash
expect -c "
spawn sudo -u jenkins -H ssh-keygen -t rsa -C jenkins@xxx.com
expect \"Enter file in which to save the key\"
send \"\n\"
expect \"Enter passphrase\"
send \"\n\"
expect \"Enter same passphrase again\"
send \"\n\"
"

参考

2
3
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
2
3