[英]how to escape quote in ssh command
I want to install a the pub key for user test
using the command below. 我想使用下面的命令安装一个发布密钥供用户test
。
I know the root password and the user test
does not exist. 我知道root密码,并且用户test
不存在。
cat test.pub | ssh root@127.0.0.1 "useradd -m test || su - test -c 'umask 077; mkdir /home/test/.ssh; cat >> /home/test/.ssh/authorized_keys'"
But the command does not work. 但是该命令不起作用。
Error: Creating mailbox file: File exists
The problem is useradd -m test
. 问题是useradd -m test
。 I delete user test by userdel test && rm -rf /home/test
. 我通过userdel test && rm -rf /home/test
删除用户userdel test && rm -rf /home/test
。 It should be userdel -r test
. 应该是userdel -r test
。
The command below works: 以下命令有效:
cat test.pub | ssh root@127.0.0.1 "useradd -m test && su - test -c 'umask 077; mkdir /home/test/.ssh; cat >> /home/test/.ssh/authorized_keys'"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.