KEY=$(cat ~/.ssh/id_rsa.pub)
ssh root@127.0.0.1 KEY="$KEY" echo "hi"
它将失败并显示如下错误:
bash: AAAAB3NzaC1yc2EAAAADAQABAAABAQDJ65FHdb8FyD...tpFnRUSZ: No such file or directory
我该如何解决?
KEY=$(cat ~/.ssh/id_rsa.pub)
ssh root@127.0.0.1 KEY="$KEY" echo "hi"
它将失败并显示如下错误:
bash: AAAAB3NzaC1yc2EAAAADAQABAAABAQDJ65FHdb8FyD...tpFnRUSZ: No such file or directory
我该如何解决?
假设使用了bash:
对于更一般的情况,如果输入中可能包含任意字符,包括引号,请考虑使用(特定于bas的)${var@A}
创建分配:
ssh root@localhost ${KEY@A} echo 'hi'
更新1:bash(4.4版)手册页:在“ @A”(和其他操作)上:
${parameter@operator} Parameter transformation. The expansion is either a transformation of the value of parameter or information about parameter itself,depending on the value of operator. Each operator is a single letter: Q The expansion is a string that is the value of parameter quoted in a format that can be reused as input. E The expansion is a string that is the value of parameter with backslash escape sequences expanded as with the $'...' quoting mechansim. P The expansion is a string that is the result of expanding the value of parameter as if it were a prompt string (see PROMPTING below). A The expansion is a string in the form of an assignment statement or declare command that,if evaluated,will recreate parameter with its attributes and value. a The expansion is a string consisting of flag values representing parameter's attributes.