Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gitlab-runner
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Seipel
gitlab-runner
Commits
135d7556
Commit
135d7556
authored
10 years ago
by
Kamil Trzcinski
Browse files
Options
Downloads
Patches
Plain Diff
Added IdentityFile support for SSH executor
parent
af913976
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docs/configuration/advanced-configuration.md
+3
-1
3 additions, 1 deletion
docs/configuration/advanced-configuration.md
ssh/ssh_command.go
+26
-3
26 additions, 3 deletions
ssh/ssh_command.go
ssh/ssh_config.go
+5
-4
5 additions, 4 deletions
ssh/ssh_config.go
with
34 additions
and
8 deletions
docs/configuration/advanced-configuration.md
+
3
−
1
View file @
135d7556
...
@@ -173,10 +173,11 @@ This defines the SSH connection parameters.
...
@@ -173,10 +173,11 @@ This defines the SSH connection parameters.
| Parameter | Explanation |
| Parameter | Explanation |
| ---------- | ----------- |
| ---------- | ----------- |
|
`host`
| where to connect (overriden when using
`docker-ssh`
) |
|
`host`
| where to connect (overrid
d
en when using
`docker-ssh`
) |
|
`port`
| specify port, default: 22 |
|
`port`
| specify port, default: 22 |
|
`user`
| specify user |
|
`user`
| specify user |
|
`password`
| specify password |
|
`password`
| specify password |
|
`identity_file`
| specify file path to SSH private key (id_rsa, id_dsa or id_edcsa). The file needs to be stored unencrypted |
Example:
Example:
...
@@ -186,6 +187,7 @@ Example:
...
@@ -186,6 +187,7 @@ Example:
port = "22"
port = "22"
user = "root"
user = "root"
password = "production-server-password"
password = "production-server-password"
identity_file = "
```
```
### Note
### Note
...
...
This diff is collapsed.
Click to expand it.
ssh/ssh_command.go
+
26
−
3
View file @
135d7556
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
"code.google.com/p/go.crypto/ssh"
"code.google.com/p/go.crypto/ssh"
"gitlab.com/gitlab-org/gitlab-ci-multi-runner/helpers"
"gitlab.com/gitlab-org/gitlab-ci-multi-runner/helpers"
"io/ioutil"
)
)
type
Command
struct
{
type
Command
struct
{
...
@@ -25,14 +26,31 @@ type Command struct {
...
@@ -25,14 +26,31 @@ type Command struct {
client
*
ssh
.
Client
client
*
ssh
.
Client
}
}
func
(
s
*
Command
)
getSSHAuthMethods
()
[]
ssh
.
AuthMethod
{
func
(
s
*
Command
)
getSSHKey
(
identityFile
string
)
(
key
ssh
.
Signer
,
err
error
)
{
buf
,
err
:=
ioutil
.
ReadFile
(
identityFile
)
if
err
!=
nil
{
return
nil
,
err
}
key
,
err
=
ssh
.
ParsePrivateKey
(
buf
)
return
key
,
err
}
func
(
s
*
Command
)
getSSHAuthMethods
()
([]
ssh
.
AuthMethod
,
error
)
{
var
methods
[]
ssh
.
AuthMethod
var
methods
[]
ssh
.
AuthMethod
if
s
.
Password
!=
nil
{
if
s
.
Password
!=
nil
{
methods
=
append
(
methods
,
ssh
.
Password
(
*
s
.
Password
))
methods
=
append
(
methods
,
ssh
.
Password
(
*
s
.
Password
))
}
}
return
methods
if
s
.
IdentityFile
!=
nil
{
key
,
err
:=
s
.
getSSHKey
(
*
s
.
IdentityFile
)
if
err
!=
nil
{
return
nil
,
err
}
methods
=
append
(
methods
,
ssh
.
PublicKeys
(
key
))
}
return
methods
,
nil
}
}
func
(
s
*
Command
)
Connect
()
error
{
func
(
s
*
Command
)
Connect
()
error
{
...
@@ -40,9 +58,14 @@ func (s *Command) Connect() error {
...
@@ -40,9 +58,14 @@ func (s *Command) Connect() error {
user
:=
helpers
.
StringOrDefault
(
s
.
User
,
"root"
)
user
:=
helpers
.
StringOrDefault
(
s
.
User
,
"root"
)
port
:=
helpers
.
StringOrDefault
(
s
.
Port
,
"22"
)
port
:=
helpers
.
StringOrDefault
(
s
.
Port
,
"22"
)
methods
,
err
:=
s
.
getSSHAuthMethods
()
if
err
!=
nil
{
return
err
}
config
:=
&
ssh
.
ClientConfig
{
config
:=
&
ssh
.
ClientConfig
{
User
:
user
,
User
:
user
,
Auth
:
s
.
getSSHAuthM
ethods
()
,
Auth
:
m
ethods
,
}
}
connectRetries
:=
s
.
ConnectRetries
connectRetries
:=
s
.
ConnectRetries
...
...
This diff is collapsed.
Click to expand it.
ssh/ssh_config.go
+
5
−
4
View file @
135d7556
package
ssh
package
ssh
type
Config
struct
{
type
Config
struct
{
User
*
string
`toml:"user" json:"user"`
User
*
string
`toml:"user" json:"user"`
Password
*
string
`toml:"password" json:"password"`
Password
*
string
`toml:"password" json:"password"`
Host
*
string
`toml:"host" json:"host"`
Host
*
string
`toml:"host" json:"host"`
Port
*
string
`toml:"port" json:"port"`
Port
*
string
`toml:"port" json:"port"`
IdentityFile
*
string
`toml:"identity_file" json:"identity_file"`
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment