忍者ブログ

ひつ(じのひよこが)プログラミングします。
お仕事や趣味で困ったこととか、何度も「あれ?どうだったかしら」と調べたりしたこととか、作ったものとか、こどものこととかを書きます
★前は週末定期更新でしたが今は不定期更新です

2024/05    04« 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  »06

su XXX できないときはログインシェルも疑う

$ hiyoko@hiyoko-server: su hitsuji
と打てば hitsuji になれるはずだった。しかし、
$ hiyoko@hiyoko-server: 特にエラーなど出ず hiyoko に戻っている。こういう現象に見舞われた。

このせいだと思うのだが、外のサーバから ssh で hitsuji として繋ごうとしてもすぐに切断されてしまう。接続まではできるのだが、即切断だ。

そんなこんなで OpenStack からインスタンスのリサイズができなくてつらい思いをしていた。

ERROR oslo_messaging.rpc.dispatcher [req-599bf23b-2f0f-4eb5-8496-b0ca8edbd865 4f525d938c244788b6bb44f5ee3b5f8c c7e5e14e38e9438da15ea276c1a04798 - - -] Exception during message handling: Resize error: not able to execute ssh command: Unexpected error while running command.
ERROR oslo_messaging.rpc.dispatcher Traceback (most recent call last):
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 142, in _dispatch_and_reply
ERROR oslo_messaging.rpc.dispatcher     executor_callback))
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 186, in _dispatch
ERROR oslo_messaging.rpc.dispatcher     executor_callback)
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 129, in _do_dispatch
ERROR oslo_messaging.rpc.dispatcher     result = func(ctxt, **new_args)
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/nova/exception.py", line 89, in wrapped
ERROR oslo_messaging.rpc.dispatcher     payload)
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 195, in __exit__
ERROR oslo_messaging.rpc.dispatcher     six.reraise(self.type_, self.value, self.tb)
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/nova/exception.py", line 72, in wrapped
ERROR oslo_messaging.rpc.dispatcher     return f(self, context, *args, **kw)
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/nova/compute/manager.py", line 350, in decorated_function
ERROR oslo_messaging.rpc.dispatcher     LOG.warning(msg, e, instance=instance)
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 195, in __exit__
ERROR oslo_messaging.rpc.dispatcher     six.reraise(self.type_, self.value, self.tb)
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/nova/compute/manager.py", line 323, in decorated_function
ERROR oslo_messaging.rpc.dispatcher     return function(self, context, *args, **kwargs)
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/nova/compute/manager.py", line 400, in decorated_function
ERROR oslo_messaging.rpc.dispatcher     return function(self, context, *args, **kwargs)
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/nova/compute/manager.py", line 311, in decorated_function
ERROR oslo_messaging.rpc.dispatcher     migration.instance_uuid, exc_info=True)
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 195, in __exit__
ERROR oslo_messaging.rpc.dispatcher     six.reraise(self.type_, self.value, self.tb)
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/nova/compute/manager.py", line 288, in decorated_function
ERROR oslo_messaging.rpc.dispatcher     return function(self, context, *args, **kwargs)
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/nova/compute/manager.py", line 378, in decorated_function
ERROR oslo_messaging.rpc.dispatcher     kwargs['instance'], e, sys.exc_info())
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 195, in __exit__
ERROR oslo_messaging.rpc.dispatcher     six.reraise(self.type_, self.value, self.tb)
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/nova/compute/manager.py", line 366, in decorated_function
ERROR oslo_messaging.rpc.dispatcher     return function(self, context, *args, **kwargs)
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/nova/compute/manager.py", line 3852, in resize_instance
ERROR oslo_messaging.rpc.dispatcher     self.instance_events.clear_events_for_instance(instance)
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
ERROR oslo_messaging.rpc.dispatcher     self.gen.throw(type, value, traceback)
ERROR oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/dist-packages/nova/compute/manager.py", line 6429, in _error_out_instance_on_exception
ERROR oslo_messaging.rpc.dispatcher     raise error.inner_exception
ERROR oslo_messaging.rpc.dispatcher ResizeError: Resize error: not able to execute ssh command: Unexpected error while running command.
ERROR oslo_messaging.rpc.dispatcher Command: ssh 192.168.2.8 mkdir -p /var/lib/nova/instances/ab6bed88-ba1d-45d8-8bc1-ce4dee9c2a4b
ERROR oslo_messaging.rpc.dispatcher Exit code: 1
ERROR oslo_messaging.rpc.dispatcher Stdout: u''
ERROR oslo_messaging.rpc.dispatcher Stderr: u"Warning: Permanently added '192.168.2.7' (ECDSA) to the list of known hosts.\r\n"

このような場合は cat /etc/passwdする。するとユーザ情報がおかしいことに気付く。
ユーザの色々な情報が詰まっているが、使いたいユーザの行末に /bin/false とあった。行末にはログインしたときに起動するシェル (ログインシェル) の情報がある。/bin/false は「何もせずに終了する」だ。su できたり ssh できたりするのに即座に絶たれるのはこれが理由だったのだ。

なんとかするには chsh コマンドを使ってログインシェルを変更してやればいい。/bin/bashとかにしておけばよい。ただ、こういうことをすれば使えるユーザがそれだけ増え、色々と面倒ごとも起こるかもしれない。よくよく考えてからすること。

PR

コメント

ただいまコメントを受けつけておりません。

ブログ内検索

P R