Skip to content
Advertisement

cat command not working as expected using ssh

I am creating a yaml file in GitHub Actions to install softwares on Linux servers created using terraform. Using the pipeline i am able to ssh into the linux servers. In one of the servers i am creating a .ssh directory and an id_rsa file (which contains the private key of the other server) which i intend to use to scp into the other server to copy some files. I have used the echo command to copy the private key to id_rsa file. I want to view the content of id_rsa to make sure the correct private key is copied. I am using the cat command but it does not work. here is my code

JavaScript

the commands run but the cat command does not return any output. It does not fail. the pipeline passes but this command does not render any output. I have tried the following combinations as well but nothing works

JavaScript

I tried this too

JavaScript

says cat command not found. I just want to view the contents of id_rsa file, not sure what i am doing wrong.

Advertisement

Answer

JavaScript

Unless $INFRA_PRIVATE_KEY is a variable set by the login environment on chefnode, this is likely to be empty.

I assume you wanted to send a variable set on the local console, but as written this literally sends "$INFRA_PRIVATE_KEY" to the server which probably expands to nothing (i.e. the file is actually empty).

you probably instead want something like:

JavaScript

which locally expands the variable and then sends it with quoting (assuming there are no quotes embedded in the variable value itself)

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement