Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
b8a8e228
Commit
b8a8e228
authored
Mar 05, 2017
by
Pål Håland
Browse files
Added deploy script to deploy to the routeros system
parent
e538a13e
Changes
2
Hide whitespace changes
Inline
Side-by-side
deploy/README.md
View file @
b8a8e228
...
...
@@ -72,3 +72,19 @@ export DEPLOY_EXIM4_RELOAD="/etc/init.d/exim4 restart"
acme.sh
--deploy
-d
ftp.example.com
--deploy-hook
exim4
```
## 6. Deploy the cert to remote routeros
```
sh
acme.sh
--deploy
-d
ftp.example.com
--deploy-hook
routeros
```
Before you can deploy the certificate to router os, you need to add the id_rsa.pub key to the routeros and assign a user to that key.
The user need to have access to ssh, ftp, read and write.
Then you need to set the environment variables for the deploy script to work.
```
sh
export
ROUTER_OS_USERNAME
=
certuser
export
ROUTER_OS_HOST
=
router.example.com
acme.sh
--deploy
-d
ftp.example.com
--deploy-hook
routeros
```
deploy/routeros.sh
0 → 100644
View file @
b8a8e228
#!/usr/bin/env bash
#Here is a script to deploy cert to routeros router.
#returns 0 means success, otherwise error.
######## Public functions #####################
#domain keyfile certfile cafile fullchain
routeros_deploy
()
{
_cdomain
=
"
$1
"
_ckey
=
"
$2
"
_ccert
=
"
$3
"
_cca
=
"
$4
"
_cfullchain
=
"
$5
"
_debug _cdomain
"
$_cdomain
"
_debug _ckey
"
$_ckey
"
_debug _ccert
"
$_ccert
"
_debug _cca
"
$_cca
"
_debug _cfullchain
"
$_cfullchain
"
if
[
-z
"
$ROUTER_OS_HOST
"
]
;
then
_err
"Need to set the env variable ROUTER_OS_HOST"
return
1
fi
if
[
-z
"
$ROUTER_OS_USERNAME
"
]
;
then
_err
"Need to set the env variable ROUTER_OS_USERNAME"
return
1
fi
_info
"Trying to push key '
$_ckey
' to router"
scp
$_ckey
$ROUTER_OS_USERNAME
@
$ROUTER_OS_HOST
:
$_cdomain
".key"
_info
"Trying to push cert '
$_ccert
' to router"
scp
$_ccert
$ROUTER_OS_USERNAME
@
$ROUTER_OS_HOST
:
$_cdomain
".cer"
_info
"Trying to push ca cert '
$_cca
' to router"
scp
$_cca
$ROUTER_OS_USERNAME
@
$ROUTER_OS_HOST
:
$_cdomain
".ca"
ssh
$ROUTER_OS_USERNAME
@
$ROUTER_OS_HOST
bash
-c
"'
/certificate remove
$_cdomain
.cer_0
/certificate remove
$_cdomain
.ca_0
delay 1
/certificate import file-name=
$_cdomain
.cer passphrase=
\"\"
/certificate import file-name=
$_cdomain
.ca passphrase=
\"\"
/certificate import file-name=
$_cdomain
.key passphrase=
\"\"
delay 1
/file remove
$_cdomain
.cer
/file remove
$_cdomain
.key
delay 2
/ip service set www-ssl certificate=
$_cdomain
.cer_0
'"
return
0
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment