liang8283 commented on issue #1832:
URL: https://github.com/apache/cloudberry/issues/1832#issuecomment-4828585719

   Embedding raw newlines in a shell command-line argument is unreliable across 
SSH, because the remote shell re-interprets the string and folds the newlines 
into spaces.
   
   You can test by using "\n" for the entries instead of the raw newline.
   
   ```
   ssh ... cloudberry_standby ". ...env.sh; \$GPHOME/sbin/seg_update_pg_hba.py 
--data-dir ... --entries \$'host replication gpadmin samehost trust\nhost all 
gpadmin 172.24.246.190/32 trust\n...'"
   ```
   
   Anyway, you can improve the script by using  stdin + base64. For example:
   
   ```
   ENTRIES='host replication gpadmin samehost trust
   host all gpadmin 172.24.246.190/32 trust
   host all gpadmin 172.17.0.1/32 trust
   host replication gpadmin 172.24.246.190/32 trust
   host replication gpadmin 172.17.0.1/32 trust
   host replication gpadmin 172.24.246.191/32 trust
   host replication gpadmin 172.17.0.1/32 trust'
   
   B64=$(printf '%s' "$ENTRIES" | base64 -w0)
   
   ssh -o StrictHostKeyChecking=no -o ServerAliveInterval=60 cloudberry_standby 
\
     "echo '$B64' | base64 -d | { . /usr/local/cloudberry/cloudberry-env.sh; 
\$GPHOME/sbin/seg_update_pg_hba.py --data-dir 
/docker/volumn_map/cloudberry/data/primary/gp_seg3 --entries-stdin; }"
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to