I have a custom shell in /bin/that returns an echo and exists.
I have a user that is exclusively linked to that shell only so that when someone tries to ssh into the server using that user via pubkey only, the custom shell will echo something and exit immediately (closes the ssh conenction right after the echo).
The problem is that it's working but it's showing the default Ubuntu MOTD / Banner after the authentication, while i only want …
我正在尝试 ssh 进入服务器并使用特定命令获取系统正常运行时间,但它无法执行。
这几乎可以在所有 UNIX 系统上本地运行
startuptime=`uptime | awk '{print $2,$3,$4,$5}'` && startuptime1=${startuptime%,} && startdayshours=${startuptime1%%:*}' Hours, ' && startminutes=${startuptime1##*:}' Minutes' && echo 'System Uptime -' $startdayshours$startminutes `date`
Run Code Online (Sandbox Code Playgroud)
但如果我这样做,它将不起作用(无论我如何更改/添加转义字符或 $() 或 `` 或 ' " ' " ' 引号等..)
ssh user@server "startuptime=`uptime | awk '{print $2,$3,$4,$5}'`; startuptime1=${startuptime%,}; startdayshours=${startuptime1%%:*}' Hours, '; startminutes=${startuptime1##*:}' Minutes'; echo 'System Uptime -' $startdayshours$startminutes `date`"
Run Code Online (Sandbox Code Playgroud)
PS:我知道它不适用于引号,因为我需要转义内部引号,但这只是一个例子ssh user@server command_goes_here