跳到主內容

【Tip】關於 bash

【Tip】無痕模式 bash

script -c /bin/bash -q /dev/null

 

這個指令使用了 `script` 工具,該工具通常用於記錄終端會話。下面是詳細解釋:

1. **`script` 工具:** `script` 是一個Unix和Linux系統上的命令行工具,它允許用戶記錄終端會話。當你啟動 `script` 時,它將開始記錄你在終端中輸入的所有命令和終端的輸出。

2. **`-c /bin/bash`:** 這部分指定了 `script` 要記錄的 shell。在這個例子中,它指定了使用 `/bin/bash` 作為要記錄的 shell。

3. **`-q`:** 這個選項使 `script` 在運行時保持安靜。它抑制了 `script` 輸出的啟動和結束消息,使其在背景運行時更為靜默。

4. **`/dev/null`:** 這是一個特殊的文件,通常被用作無效的輸出或輸入。在這裡,它被用作 `script` 的輸出文件,這意味著終端會話的記錄將被寫入 `/dev/null`,即被丟棄,而不會寫入實際的文件。

總的來說,這條指令的目的是以安靜的方式記錄 `/bin/bash` shell 的所有命令和終端輸出,並將記錄輸出到 `/dev/null`,從而達到不保存實際記錄的效果。這樣的操作在某些情況下可能被用於紀錄或監控終端活動,但要注意潛在的濫用風險,特別是在未經授權的情況下使用此類工具。


【Tip】使用 bash

有些ssh 不是使用bash(或是切換權限不足) ,登入後會出現 stdin is not a terminal

listening on [any] 443 ...
connect to [192.168.45.187] from (UNKNOWN) [192.168.194.63] 54132
bash: cannot set terminal process group (2309): Inappropriate ioctl for device
bash: no job control in this shell
bash: /root/.bashrc: Permission denied
confluence@confluence01:/opt/atlassian/confluence/bin$ ssh database_admin@10.4.194.215
<ian/confluence/bin$ ssh database_admin@10.4.194.215   
Pseudo-terminal will not be allocated because stdin is not a terminal.
Could not create directory '/home/confluence/.ssh'.
Host key verification failed.

使用phton 切換

python3 -c 'import pty; pty.spawn("/bin/bash")'