Remote ssh script execution with EOI or EOSSH adding . in front of commands
I have a script and this is a part of it, where it is logging to a remote server via ssh to execute some commands. Here it is:
ssh -tt -vvv -i $pathToPem -o StrictHostKeyChecking=no $sshUsernameIp << EOI
sudo rm -rf letsencrypt.tar.gz /etc/letsencrypt /usr/local/share/ca-certificates/chain.crt
sed -e 1b -e '$!d' /home/ubuntu/.bashrc
sudo add-apt-repository ppa:certbot/certbot -y
sudo apt-get install certbot -y ######
sudo certbot certonly -n --agree-tos --register-unsafely-without-email --standalone -d $FQDN
sudo chown -R root:sudo /etc/letsencrypt/
sudo chmod -R 750 /etc/letsencrypt/
sudo chmod -R 644 /usr/local/share/
sudo cp /etc/letsencrypt/live/$FQDN/chain.pem /usr/local/share/ca-certificates/chain.crt
sudo update-ca-certificates
sudo tar -czvf letsencrypt.tar.gz /etc/letsencrypt
exit
EOI
It works fine till this ###### line and after that it does not execute the remaining commands. It says this:
Created symlink /etc/systemd/system/timers.target.wants/certbot.timer → /lib/systemd/system/certbot.timer.
certbot.service is a disabled or a static unit, not starting it.
But, after that if I Control+C and then rerun the code again, this time it executes all commands and then exits.
So, I thought of splitting up into two like the following, is it a bad solution or will it work when certbot will be newly installed? I guess, this is working now because, certbot is already installed into the system, I was wondering what would be best solution get away with this.
ssh -tt -vvv -i $pathToPem -o StrictHostKeyChecking=no $sshUsernameIp << EOI
sudo rm -rf letsencrypt.tar.gz
sudo rm -rf /etc/letsencrypt
sudo rm -rf /usr/local/share/ca-certificates/chain.crt
sed -e 1b -e '$!d' $remote_home_dir/.bashrc
sudo add-apt-repository ppa:certbot/certbot -y
sudo apt-get install certbot -y &
exit
trap exit INT
EOI
###############
ssh -tt -vvv -i $pathToPem -o StrictHostKeyChecking=no $sshUsernameIp << EOI
sudo certbot certonly -n --agree-tos --register-unsafely-without-email --standalone -d $FQDN
sudo chown -R root:sudo /etc/letsencrypt/
sudo chmod -R 750 /etc/letsencrypt/
sudo chmod -R 644 /usr/local/share/
sudo cp /etc/letsencrypt/live/$FQDN/chain.pem /usr/local/share/ca-certificates/chain.crt
sudo update-ca-certificates
sudo tar -czvf letsencrypt.tar.gz /etc/letsencrypt
exit
EOI
Updated
Now, the first part works, when it goes to second part begins at line ############### it says the following:
Command '.sudo' not found, did you mean:
command 'sudo' from deb sudo
command 'sudo' from deb sudo-ldap
Try: sudo apt install <deb name>
Someone shared a solution before but later removed it, I think that would work for me. :)
Why is it adding "." in front of all commands?
bash shell-script ssh remote
add a comment |
I have a script and this is a part of it, where it is logging to a remote server via ssh to execute some commands. Here it is:
ssh -tt -vvv -i $pathToPem -o StrictHostKeyChecking=no $sshUsernameIp << EOI
sudo rm -rf letsencrypt.tar.gz /etc/letsencrypt /usr/local/share/ca-certificates/chain.crt
sed -e 1b -e '$!d' /home/ubuntu/.bashrc
sudo add-apt-repository ppa:certbot/certbot -y
sudo apt-get install certbot -y ######
sudo certbot certonly -n --agree-tos --register-unsafely-without-email --standalone -d $FQDN
sudo chown -R root:sudo /etc/letsencrypt/
sudo chmod -R 750 /etc/letsencrypt/
sudo chmod -R 644 /usr/local/share/
sudo cp /etc/letsencrypt/live/$FQDN/chain.pem /usr/local/share/ca-certificates/chain.crt
sudo update-ca-certificates
sudo tar -czvf letsencrypt.tar.gz /etc/letsencrypt
exit
EOI
It works fine till this ###### line and after that it does not execute the remaining commands. It says this:
Created symlink /etc/systemd/system/timers.target.wants/certbot.timer → /lib/systemd/system/certbot.timer.
certbot.service is a disabled or a static unit, not starting it.
But, after that if I Control+C and then rerun the code again, this time it executes all commands and then exits.
So, I thought of splitting up into two like the following, is it a bad solution or will it work when certbot will be newly installed? I guess, this is working now because, certbot is already installed into the system, I was wondering what would be best solution get away with this.
ssh -tt -vvv -i $pathToPem -o StrictHostKeyChecking=no $sshUsernameIp << EOI
sudo rm -rf letsencrypt.tar.gz
sudo rm -rf /etc/letsencrypt
sudo rm -rf /usr/local/share/ca-certificates/chain.crt
sed -e 1b -e '$!d' $remote_home_dir/.bashrc
sudo add-apt-repository ppa:certbot/certbot -y
sudo apt-get install certbot -y &
exit
trap exit INT
EOI
###############
ssh -tt -vvv -i $pathToPem -o StrictHostKeyChecking=no $sshUsernameIp << EOI
sudo certbot certonly -n --agree-tos --register-unsafely-without-email --standalone -d $FQDN
sudo chown -R root:sudo /etc/letsencrypt/
sudo chmod -R 750 /etc/letsencrypt/
sudo chmod -R 644 /usr/local/share/
sudo cp /etc/letsencrypt/live/$FQDN/chain.pem /usr/local/share/ca-certificates/chain.crt
sudo update-ca-certificates
sudo tar -czvf letsencrypt.tar.gz /etc/letsencrypt
exit
EOI
Updated
Now, the first part works, when it goes to second part begins at line ############### it says the following:
Command '.sudo' not found, did you mean:
command 'sudo' from deb sudo
command 'sudo' from deb sudo-ldap
Try: sudo apt install <deb name>
Someone shared a solution before but later removed it, I think that would work for me. :)
Why is it adding "." in front of all commands?
bash shell-script ssh remote
add a comment |
I have a script and this is a part of it, where it is logging to a remote server via ssh to execute some commands. Here it is:
ssh -tt -vvv -i $pathToPem -o StrictHostKeyChecking=no $sshUsernameIp << EOI
sudo rm -rf letsencrypt.tar.gz /etc/letsencrypt /usr/local/share/ca-certificates/chain.crt
sed -e 1b -e '$!d' /home/ubuntu/.bashrc
sudo add-apt-repository ppa:certbot/certbot -y
sudo apt-get install certbot -y ######
sudo certbot certonly -n --agree-tos --register-unsafely-without-email --standalone -d $FQDN
sudo chown -R root:sudo /etc/letsencrypt/
sudo chmod -R 750 /etc/letsencrypt/
sudo chmod -R 644 /usr/local/share/
sudo cp /etc/letsencrypt/live/$FQDN/chain.pem /usr/local/share/ca-certificates/chain.crt
sudo update-ca-certificates
sudo tar -czvf letsencrypt.tar.gz /etc/letsencrypt
exit
EOI
It works fine till this ###### line and after that it does not execute the remaining commands. It says this:
Created symlink /etc/systemd/system/timers.target.wants/certbot.timer → /lib/systemd/system/certbot.timer.
certbot.service is a disabled or a static unit, not starting it.
But, after that if I Control+C and then rerun the code again, this time it executes all commands and then exits.
So, I thought of splitting up into two like the following, is it a bad solution or will it work when certbot will be newly installed? I guess, this is working now because, certbot is already installed into the system, I was wondering what would be best solution get away with this.
ssh -tt -vvv -i $pathToPem -o StrictHostKeyChecking=no $sshUsernameIp << EOI
sudo rm -rf letsencrypt.tar.gz
sudo rm -rf /etc/letsencrypt
sudo rm -rf /usr/local/share/ca-certificates/chain.crt
sed -e 1b -e '$!d' $remote_home_dir/.bashrc
sudo add-apt-repository ppa:certbot/certbot -y
sudo apt-get install certbot -y &
exit
trap exit INT
EOI
###############
ssh -tt -vvv -i $pathToPem -o StrictHostKeyChecking=no $sshUsernameIp << EOI
sudo certbot certonly -n --agree-tos --register-unsafely-without-email --standalone -d $FQDN
sudo chown -R root:sudo /etc/letsencrypt/
sudo chmod -R 750 /etc/letsencrypt/
sudo chmod -R 644 /usr/local/share/
sudo cp /etc/letsencrypt/live/$FQDN/chain.pem /usr/local/share/ca-certificates/chain.crt
sudo update-ca-certificates
sudo tar -czvf letsencrypt.tar.gz /etc/letsencrypt
exit
EOI
Updated
Now, the first part works, when it goes to second part begins at line ############### it says the following:
Command '.sudo' not found, did you mean:
command 'sudo' from deb sudo
command 'sudo' from deb sudo-ldap
Try: sudo apt install <deb name>
Someone shared a solution before but later removed it, I think that would work for me. :)
Why is it adding "." in front of all commands?
bash shell-script ssh remote
I have a script and this is a part of it, where it is logging to a remote server via ssh to execute some commands. Here it is:
ssh -tt -vvv -i $pathToPem -o StrictHostKeyChecking=no $sshUsernameIp << EOI
sudo rm -rf letsencrypt.tar.gz /etc/letsencrypt /usr/local/share/ca-certificates/chain.crt
sed -e 1b -e '$!d' /home/ubuntu/.bashrc
sudo add-apt-repository ppa:certbot/certbot -y
sudo apt-get install certbot -y ######
sudo certbot certonly -n --agree-tos --register-unsafely-without-email --standalone -d $FQDN
sudo chown -R root:sudo /etc/letsencrypt/
sudo chmod -R 750 /etc/letsencrypt/
sudo chmod -R 644 /usr/local/share/
sudo cp /etc/letsencrypt/live/$FQDN/chain.pem /usr/local/share/ca-certificates/chain.crt
sudo update-ca-certificates
sudo tar -czvf letsencrypt.tar.gz /etc/letsencrypt
exit
EOI
It works fine till this ###### line and after that it does not execute the remaining commands. It says this:
Created symlink /etc/systemd/system/timers.target.wants/certbot.timer → /lib/systemd/system/certbot.timer.
certbot.service is a disabled or a static unit, not starting it.
But, after that if I Control+C and then rerun the code again, this time it executes all commands and then exits.
So, I thought of splitting up into two like the following, is it a bad solution or will it work when certbot will be newly installed? I guess, this is working now because, certbot is already installed into the system, I was wondering what would be best solution get away with this.
ssh -tt -vvv -i $pathToPem -o StrictHostKeyChecking=no $sshUsernameIp << EOI
sudo rm -rf letsencrypt.tar.gz
sudo rm -rf /etc/letsencrypt
sudo rm -rf /usr/local/share/ca-certificates/chain.crt
sed -e 1b -e '$!d' $remote_home_dir/.bashrc
sudo add-apt-repository ppa:certbot/certbot -y
sudo apt-get install certbot -y &
exit
trap exit INT
EOI
###############
ssh -tt -vvv -i $pathToPem -o StrictHostKeyChecking=no $sshUsernameIp << EOI
sudo certbot certonly -n --agree-tos --register-unsafely-without-email --standalone -d $FQDN
sudo chown -R root:sudo /etc/letsencrypt/
sudo chmod -R 750 /etc/letsencrypt/
sudo chmod -R 644 /usr/local/share/
sudo cp /etc/letsencrypt/live/$FQDN/chain.pem /usr/local/share/ca-certificates/chain.crt
sudo update-ca-certificates
sudo tar -czvf letsencrypt.tar.gz /etc/letsencrypt
exit
EOI
Updated
Now, the first part works, when it goes to second part begins at line ############### it says the following:
Command '.sudo' not found, did you mean:
command 'sudo' from deb sudo
command 'sudo' from deb sudo-ldap
Try: sudo apt install <deb name>
Someone shared a solution before but later removed it, I think that would work for me. :)
Why is it adding "." in front of all commands?
bash shell-script ssh remote
bash shell-script ssh remote
edited 5 mins ago
Rakib Fiha
asked 11 hours ago
Rakib FihaRakib Fiha
217
217
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503620%2fremote-ssh-script-execution-with-eoi-or-eossh-adding-in-front-of-commands%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503620%2fremote-ssh-script-execution-with-eoi-or-eossh-adding-in-front-of-commands%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown