Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
956b9ded
Commit
956b9ded
authored
Apr 10, 2015
by
Vilmos Nebehaj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try another ssh port if the current one is taken.
parent
b49d74d9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
builder/qemu/step_forward_ssh.go
builder/qemu/step_forward_ssh.go
+5
-0
builder/virtualbox/common/step_forward_ssh.go
builder/virtualbox/common/step_forward_ssh.go
+5
-0
No files found.
builder/qemu/step_forward_ssh.go
View file @
956b9ded
...
...
@@ -34,12 +34,17 @@ func (s *stepForwardSSH) Run(state multistep.StateBag) multistep.StepAction {
for
{
sshHostPort
=
offset
+
config
.
SSHHostPortMin
if
sshHostPort
>=
config
.
SSHHostPortMax
{
offset
=
0
sshHostPort
=
config
.
SSHHostPortMin
}
log
.
Printf
(
"Trying port: %d"
,
sshHostPort
)
l
,
err
:=
net
.
Listen
(
"tcp"
,
fmt
.
Sprintf
(
":%d"
,
sshHostPort
))
if
err
==
nil
{
defer
l
.
Close
()
break
}
offset
++
}
ui
.
Say
(
fmt
.
Sprintf
(
"Found port for SSH: %d."
,
sshHostPort
))
...
...
builder/virtualbox/common/step_forward_ssh.go
View file @
956b9ded
...
...
@@ -42,12 +42,17 @@ func (s *StepForwardSSH) Run(state multistep.StateBag) multistep.StepAction {
for
{
sshHostPort
=
offset
+
s
.
HostPortMin
if
sshHostPort
>=
s
.
HostPortMax
{
offset
=
0
sshHostPort
=
s
.
HostPortMin
}
log
.
Printf
(
"Trying port: %d"
,
sshHostPort
)
l
,
err
:=
net
.
Listen
(
"tcp"
,
fmt
.
Sprintf
(
"127.0.0.1:%d"
,
sshHostPort
))
if
err
==
nil
{
defer
l
.
Close
()
break
}
offset
++
}
// Create a forwarded port mapping to the VM
...
...
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