小编Vik*_*ova的帖子

Disable SSH MOTD/Banner for a specific user

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 …

linux ssh ubuntu motd banner

4
推荐指数
1
解决办法
1万
查看次数

通过 ssh 从另一台服务器获取此命令的输出

我正在尝试 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

linux shell ssh quoting

2
推荐指数
1
解决办法
3万
查看次数

标签 统计

linux ×2

ssh ×2

banner ×1

motd ×1

quoting ×1

shell ×1

ubuntu ×1