ssh跟motd的幾個問題 - Linux

By Oliver
at 2011-09-22T22:17
at 2011-09-22T22:17
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'
--
但我沒有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'
--
Tags:
Linux
All Comments

By Eartha
at 2011-09-24T08:36
at 2011-09-24T08:36

By Edwina
at 2011-09-25T07:45
at 2011-09-25T07:45
Related Posts
這邊可以問cluster的問題嗎??

By Ida
at 2011-09-21T22:34
at 2011-09-21T22:34
利用伺服器Proxy封鎖區域網路內某一IP

By Delia
at 2011-09-21T19:32
at 2011-09-21T19:32
非官方 AMD & NVIDIA Graphics Drivers PPAs for maverick/natty

By Jacob
at 2011-09-21T18:35
at 2011-09-21T18:35
如何判斷是否正在tty下使用screen/tmux

By Sarah
at 2011-09-21T17:41
at 2011-09-21T17:41
Pidgin無法登入(LMDE)

By Yuri
at 2011-09-21T13:20
at 2011-09-21T13:20