Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
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
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-RAN
Commits
87d1a53c
Commit
87d1a53c
authored
Jul 14, 2022
by
Robert Schmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CI: Allow publickey authentication in SSHConnection
For pubkey, checks that we are on the right machine
parent
5928d571
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
ci-scripts/sshconnection.py
ci-scripts/sshconnection.py
+8
-6
No files found.
ci-scripts/sshconnection.py
View file @
87d1a53c
...
...
@@ -60,7 +60,7 @@ class SSHConnection():
count
=
0
connect_status
=
False
while
count
<
4
:
self
.
ssh
=
pexpect
.
spawn
(
'ssh -o PubkeyAuthentication=
no
{}@{}'
.
format
(
username
,
ipaddress
))
self
.
ssh
=
pexpect
.
spawn
(
'ssh -o PubkeyAuthentication=
yes
{}@{}'
.
format
(
username
,
ipaddress
))
# Longer timeout at connection due to asterix slowness
self
.
ssh
.
timeout
=
25
self
.
sshresponse
=
self
.
ssh
.
expect
([
'Are you sure you want to continue connecting (yes/no)?'
,
'password:'
,
'Last login'
,
pexpect
.
EOF
,
pexpect
.
TIMEOUT
])
...
...
@@ -85,13 +85,15 @@ class SSHConnection():
logging
.
debug
(
'self.sshresponse = '
+
str
(
self
.
sshresponse
))
elif
self
.
sshresponse
==
2
:
# Checking if we are really on the remote client defined by its IP address
self
.
command
(
'stdbuf -o0 ifconfig | egrep --color=never "inet addr:|inet "'
,
prompt
,
5
)
result
=
re
.
search
(
str
(
ipaddress
),
str
(
self
.
ssh
.
before
))
if
result
is
None
:
self
.
close
()
else
:
self
.
ssh
.
sendline
(
'stdbuf -o0 ifconfig | egrep --color=never "inet addr:|inet "'
)
self
.
sshresponse
=
self
.
ssh
.
expect
([
ipaddress
,
pexpect
.
EOF
,
pexpect
.
TIMEOUT
])
if
self
.
sshresponse
==
0
:
count
=
10
connect_status
=
True
# this expect seems to be necessary to advance the read buffer until the prompt, or getBefore() will not return the last command
self
.
sshresponse
=
self
.
ssh
.
expect
([
prompt
])
else
:
logging
.
error
(
'logged in to '
+
ipaddress
+
' without password but IP is not found via ifconfig on remote host, aborting'
)
else
:
# debug output
logging
.
debug
(
str
(
self
.
ssh
.
before
))
...
...
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