Answer the question
In order to leave comments, you need to log in
Why doesn't the variable work in ssh inside a bash script?
I'm trying to create a file on the server using data from a variable
#!/bin/bash
nginx_default_page="server {
listen 80;
listen [::]:80;
location / {
proxy_pass http://127.0.0.1:3000;
}
error_page 500 502 503 504 /custom_50x;
location = /custom_50x {
root /usr/share/nginx/html;
default_type application/json;
internal;
}
}
"
ssh $user@$host << 'ENDSSH'
echo "$nginx_default_page" | sudo tee /etc/nginx/conf.d/default.conf
ENDSSH
default.conf
. Why, how to fix?
Answer the question
In order to leave comments, you need to log in
VAR="blablabla
blablabla"
echo "$VAR" | ssh $user@$host 'cat>/tmp/file'
ssh $user@$host "sudo cp /tmp/file /etc;rm /tmp/file"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question