Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
su doesn't have a -S option. He must have meant sudo. Also the statement in parentheses is true for both #1 and #2.
Source Link

There are several ways to do it.

1:

ssh user@remote_server 'bash -s' < localfile 

2:

cat localfile | ssh user@remote_server 

3:

ssh user@remote_server "$(< localfile)" 

number 3 is my prefered way, it allows interactive commands e.g. susudo -S service nginx restart

(#1 and #2 will consume the rest of the script as input for the password question when you use susudo -S.)

There are several ways to do it.

1:

ssh user@remote_server 'bash -s' < localfile 

2:

cat localfile | ssh user@remote_server 

3:

ssh user@remote_server "$(< localfile)" 

number 3 is my prefered way, it allows interactive commands e.g. su -S service nginx restart

(#1 will consume the rest of the script as input for the password question when you use su -S.)

There are several ways to do it.

1:

ssh user@remote_server 'bash -s' < localfile 

2:

cat localfile | ssh user@remote_server 

3:

ssh user@remote_server "$(< localfile)" 

number 3 is my prefered way, it allows interactive commands e.g. sudo -S service nginx restart

(#1 and #2 will consume the rest of the script as input for the password question when you use sudo -S.)

Commonmark migration
Source Link

There are several ways to do it.

#1: ssh user@remote_server 'bash -s' < localfile

1:

#2: cat localfile | ssh user@remote_server

ssh user@remote_server 'bash -s' < localfile 

#3: ssh user@remote_server "$(< localfile)"

2:

cat localfile | ssh user@remote_server 

3:

ssh user@remote_server "$(< localfile)" 

number 3 is my prefered way, it allows interactive commands e.g. su -S service nginx restart

(#1 will consume the rest of the script as input for the password question when you use su -S.)

There are several ways to do it.

#1: ssh user@remote_server 'bash -s' < localfile

#2: cat localfile | ssh user@remote_server

#3: ssh user@remote_server "$(< localfile)"

number 3 is my prefered way, it allows interactive commands e.g. su -S service nginx restart

(#1 will consume the rest of the script as input for the password question when you use su -S.)

There are several ways to do it.

1:

ssh user@remote_server 'bash -s' < localfile 

2:

cat localfile | ssh user@remote_server 

3:

ssh user@remote_server "$(< localfile)" 

number 3 is my prefered way, it allows interactive commands e.g. su -S service nginx restart

(#1 will consume the rest of the script as input for the password question when you use su -S.)

Source Link

There are several ways to do it.

#1: ssh user@remote_server 'bash -s' < localfile

#2: cat localfile | ssh user@remote_server

#3: ssh user@remote_server "$(< localfile)"

number 3 is my prefered way, it allows interactive commands e.g. su -S service nginx restart

(#1 will consume the rest of the script as input for the password question when you use su -S.)