![SSH 用户名中的特殊字符未传递到远程设备](https://linux22.com/image/183640/SSH%20%E7%94%A8%E6%88%B7%E5%90%8D%E4%B8%AD%E7%9A%84%E7%89%B9%E6%AE%8A%E5%AD%97%E7%AC%A6%E6%9C%AA%E4%BC%A0%E9%80%92%E5%88%B0%E8%BF%9C%E7%A8%8B%E8%AE%BE%E5%A4%87.png)
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
为第三个位置参数的值。如果该值不存在或为空,则字符串将传递给ssh
as D5Pr
。
为了避免 shell 展开$3
,请确保在字符串周围使用单引号,例如,
ssh -c 3des-cbc 'D5P$3r@Router'
...或者逃避$
,
ssh -c 3des-cbc D5P\$3r@Router