ssh跟motd的幾個問題 - Linux

Table of Contents

1. 我想 ssh 到遠端伺服器時不顯示 motd

但我沒有root權限 這樣該怎麼弄?

(我希望只影響到我一個人 也就是其他user依然可看到motd)

(目前我的替代方案是:

ssh -t user@remote_host 'clear; bash -login'

但這方法的缺點是會把螢幕內容整個清空 連我不想清空的部分也是)

[補充: 已找到解法]

法一

touch ~/.hushlogin

法二

ssh -t user@remote_host 'bash -login'

法三(推薦這個, 僅在motd與上次登入不同時才顯示)

在.bashrc中加入:
cmp -s $HOME/.hushlogin /etc/motd;
if [ $? != 0 ]; then tee $HOME/.hushlogin < /etc/motd; fi;

ref: http://kb.iu.edu/data/acdd.html

2. 我ssh到 A 工作站後 這個檔案會自動產生:

~/.cache/motd.legal-displayed

它是一個size為零的空檔案

但我ssh到 B 工作站時不會產生這個檔案

我比較了A跟B的/etc/ssh/sshd_config 發現內容相同

這樣為什麼ssh到A會產生這個檔案 ssh到B卻不會呢?

另外 要怎麼避免產生這個檔案?


3. user@remote_host:~$ exit
logout
Connection to remote_host closed
user@local_host:~$

有辦法設定成exit後不顯示黃色那兩行嗎? how?

[補充: 已找到解法]

法一

在.bashrc中加入:

alias ssh='ssh -q'
[[ `echo $(shopt|grep login_shell)` =~ 'on' ]] && alias exit='logout'

--

All Comments

Eartha avatarEartha2011-09-24
這個似乎是你的SSH client的訊息....
Edwina avatarEdwina2011-09-25
"這個"=那兩行黃色的