SSH 用户名中的特殊字符未传递到远程设备

SSH 用户名中的特殊字符未传递到远程设备

I've been trying to beat my head around this. Bing, Google, and Yahoo don't seem to get my question, hence here I am.

I have a user D5P$3r that I need to pass from my Linux Server to my router.

I've tried the following.

ssh -c 3des-cbc D5P$3r@Router
ssh -l D5P$3r Router 
ssh -c 3des-cbc -o User=D5P$3r Router 

No matter what, the end result is:

D5Pr@Router's password:

I'm not in engineering, so my ideas are ignored hence the reason why this user was even used.

Basically I'm just trying to see how I can get the $3 to pass through to the Router's username.

The Linux Server is Red Hat Enterprise 7.6.

答案1

$3是第三个位置参数(通常是赋予当前 shell 或 shell 函数的第三个参数)。由于您的字符串D5P$3r未加引号,因此 shell 将扩展$3为第三个位置参数的值。如果该值不存在或为空,则字符串将传递给sshas D5Pr

为了避免 shell 展开$3,请确保在字符串周围使用单引号,例如,

ssh -c 3des-cbc 'D5P$3r@Router'

...或者逃避$

ssh -c 3des-cbc D5P\$3r@Router

相关内容