Skip to content
GitLab
Explore
Sign in
Commits on Source (4)
Add the option to change SSH_USER and SSH_PORT
· 7a23a1b7
ThorstenHeck
authored
Jan 23, 2022
7a23a1b7
Add SSH usage to readme
· d4348881
ThorstenHeck
authored
Jan 23, 2022
d4348881
Merge pull request #77 from ThorstenHeck/master
· 0ffaf03e
Jonas Stoehr
authored
Jan 23, 2022
Add the possibility to change SSH Port and SSH User
0ffaf03e
docs: Draft release 3.7.0
· 045f23ef
JonasS
authored
Jan 23, 2022
045f23ef
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
045f23ef
...
...
@@ -15,8 +15,8 @@ You can find sources and pre-compiled binaries [here](https://github.com/JonasPr
```
bash
# Download the binary (this example downloads the binary for linux amd64)
$
wget https://github.com/JonasProgrammer/docker-machine-driver-hetzner/releases/download/3.
6
.0/docker-machine-driver-hetzner_3.
6
.0_linux_amd64.tar.gz
$
tar
-xvf
docker-machine-driver-hetzner_3.
6
.0_linux_amd64.tar.gz
$
wget https://github.com/JonasProgrammer/docker-machine-driver-hetzner/releases/download/3.
7
.0/docker-machine-driver-hetzner_3.
7
.0_linux_amd64.tar.gz
$
tar
-xvf
docker-machine-driver-hetzner_3.
7
.0_linux_amd64.tar.gz
# Make it executable and copy the binary in a directory accessible with your $PATH
$
chmod
+x docker-machine-driver-hetzner
...
...
@@ -108,6 +108,8 @@ $ docker-machine create \
-
`--hetzner-key-label`
:
`key=value`
pairs of additional metadata to assign to SSH key (only applies if newly creadted).
-
`--hetzner-placement-group`
: Add to a placement group by name or ID; a spread-group will be created on demand if it does not exist
-
`--hetzner-auto-spread`
: Add to a
`docker-machine`
provided
`spread`
group (mutually exclusive with
`--hetzner-placement-group`
)
-
`--hetzner-ssh-user`
: Change the default SSH-User
-
`--hetzner-ssh-port`
: Change the default SSH-Port
#### Existing SSH keys
...
...
@@ -145,6 +147,9 @@ was used during creation.
|
`--hetzner-key-label`
| (inoperative) |
`[]`
|
|
`--hetzner-placement-group`
|
`HETZNER_PLACEMENT_GROUP`
| |
|
`--hetzner-auto-spread`
|
`HETZNER_AUTO_SPREAD`
| false |
|
`--hetzner-ssh-user`
|
`HETZNER_SSH_USER`
| root |
|
`--hetzner-ssh-port`
|
`HETZNER_SSH_PORT`
| 22 |
## Building from source
...
...
driver.go
View file @
045f23ef
...
...
@@ -76,11 +76,17 @@ const (
flagPlacementGroup
=
"hetzner-placement-group"
flagAutoSpread
=
"hetzner-auto-spread"
flagSshUser
=
"hetzner-ssh-user"
flagSshPort
=
"hetzner-ssh-port"
labelNamespace
=
"docker-machine"
labelAutoSpreadPg
=
"auto-spread"
labelAutoCreated
=
"auto-created"
autoSpreadPgName
=
"__auto_spread"
defaultSSHPort
=
22
defaultSSHUser
=
"root"
)
// NewDriver initializes a new driver instance; see [drivers.Driver.NewDriver]
...
...
@@ -90,8 +96,6 @@ func NewDriver() *Driver {
Type
:
defaultType
,
IsExistingKey
:
false
,
BaseDriver
:
&
drivers
.
BaseDriver
{
SSHUser
:
drivers
.
DefaultSSHUser
,
SSHPort
:
drivers
.
DefaultSSHPort
,
},
}
}
...
...
@@ -203,6 +207,18 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Name
:
flagAutoSpread
,
Usage
:
"Auto-spread on a docker-machine-specific default placement group"
,
},
mcnflag
.
StringFlag
{
EnvVar
:
"HETZNER_SSH_USER"
,
Name
:
flagSshUser
,
Usage
:
"SSH username"
,
Value
:
defaultSSHUser
,
},
mcnflag
.
IntFlag
{
EnvVar
:
"HETZNER_SSH_PORT"
,
Name
:
flagSshPort
,
Usage
:
"SSH port"
,
Value
:
defaultSSHPort
,
},
}
}
...
...
@@ -224,6 +240,9 @@ func (d *Driver) SetConfigFromFlags(opts drivers.DriverOptions) error {
d
.
Firewalls
=
opts
.
StringSlice
(
flagFirewalls
)
d
.
AdditionalKeys
=
opts
.
StringSlice
(
flagAdditionalKeys
)
d
.
SSHUser
=
opts
.
String
(
flagSshUser
)
d
.
SSHPort
=
opts
.
Int
(
flagSshPort
)
d
.
placementGroup
=
opts
.
String
(
flagPlacementGroup
)
if
opts
.
Bool
(
flagAutoSpread
)
{
if
d
.
placementGroup
!=
""
{
...
...
@@ -250,6 +269,14 @@ func (d *Driver) SetConfigFromFlags(opts drivers.DriverOptions) error {
return
nil
}
func
(
d
*
Driver
)
GetSSHUsername
()
string
{
return
d
.
SSHUser
}
func
(
d
*
Driver
)
GetSSHPort
()
(
int
,
error
)
{
return
d
.
SSHPort
,
nil
}
func
(
d
*
Driver
)
setLabelsFromFlags
(
opts
drivers
.
DriverOptions
)
error
{
d
.
ServerLabels
=
make
(
map
[
string
]
string
)
for
_
,
label
:=
range
opts
.
StringSlice
(
flagServerLabel
)
{
...
...