/etc/profile.d のスクリプトが終了状態 1 で終了したため、サーバーに SSH で接続できません。 [閉じる]

/etc/profile.d のスクリプトが終了状態 1 で終了したため、サーバーに SSH で接続できません。 [閉じる]

だからこの問題が発生しました。 SSHを使用してサーバーにログインできません。望むより:

ssh -v myuser@myserver
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Last login: Sun Jul  5 20:10:54 2015 from x.x.x.x
-bash: KSH_VERSION: unbound variable
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0
debug1: channel 0: free: client-session, nchannels 1
Connection to x.x.x.x closed.
Transferred: sent 2264, received 2800 bytes, in 0.2 seconds
Bytes per second: sent 13241.8, received 16376.8
debug1: Exit status 1

問題は、「-bash:KSH_VERSION:unbound変数」によって接続が失われているようです。なぜこれが起こるのかわかります...私は/etc/profile.dに入れるスクリプトを書いていますが、そのスクリプトには "set -euo Pipelinefail"があります(申し訳ありません)... "o"オプションは "nounset"で、これは「バインドされていない変数」を説明します...スクリプトがオプションを設定すると、バインドされていない変数でvim.shが失敗します。

今、この問題をどのように解決するのですか? SSH経由でファイル削除コマンドを送信できません。たとえば、他のユーザーとしてログインできず、他のシェルを使用できず、「--noprofile」および「--norc」オプションbashが機能しません。 ...私が試したことはどんなトリックも動作しません...

どんなアイデアがありますか?

ベストアンサー1

私も同じ問題がありましたが、ついに解決策を見つけました。

@nkmsが述べたように:

/etc/profileをインポートする前にログインプロセスを中断する(Ctrl + C)確率は約1/3(少なくとも私は1/3)です。

確率を上げるために、次のループを使用しました。

$ (trap '' INT; while true; do ssh myuser@myserver; done)

スクリプトはサブシェル '(' を起動し、そのサブシェルの ctr-c コマンドを無効にします (trap コマンドを使用)、その後 ssh コマンドを繰り返します.これが増加し、適切な瞬間を捉えること。

...奇跡的に動作します!

おすすめ記事