Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Crans Passwords
Manage
Activity
Members
Labels
Plan
Issues
5
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Nounous
Crans Passwords
Commits
46a80fe4
Verified
Commit
46a80fe4
authored
4 years ago
by
me5na7qbjqbrp
Browse files
Options
Downloads
Patches
Plain Diff
Add SSH password prompt
parent
5865912d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#3115
passed with warnings with stages
in 3 minutes and 20 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cpasswords/remote.py
+10
-3
10 additions, 3 deletions
cpasswords/remote.py
with
10 additions
and
3 deletions
cpasswords/remote.py
+
10
−
3
View file @
46a80fe4
...
@@ -9,11 +9,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
...
@@ -9,11 +9,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
"""
"""
from
functools
import
lru_cache
from
functools
import
lru_cache
from
getpass
import
getpass
import
json
import
json
import
logging
import
logging
from
paramiko.client
import
SSHClient
from
paramiko.client
import
SSHClient
from
paramiko.ssh_exception
import
SSHException
from
paramiko.ssh_exception
import
SSHException
,
PasswordRequiredException
,
AuthenticationException
from
.locale
import
_
from
.locale
import
_
...
@@ -22,7 +23,7 @@ log = logging.getLogger(__name__)
...
@@ -22,7 +23,7 @@ log = logging.getLogger(__name__)
@lru_cache
()
@lru_cache
()
def
create_ssh_client
(
host
):
def
create_ssh_client
(
host
,
password
=
None
):
"""
"""
Create a SSH client with paramiko module
Create a SSH client with paramiko module
"""
"""
...
@@ -30,7 +31,13 @@ def create_ssh_client(host):
...
@@ -30,7 +31,13 @@ def create_ssh_client(host):
client
=
SSHClient
()
client
=
SSHClient
()
client
.
load_system_host_keys
()
client
.
load_system_host_keys
()
try
:
try
:
client
.
connect
(
host
)
client
.
connect
(
host
,
password
=
password
)
except
PasswordRequiredException
:
password
=
getpass
(
"
SSH password:
"
)
return
create_ssh_client
(
host
,
password
)
except
AuthenticationException
:
log
.
error
(
_
(
"
SSH authentication failed.
"
))
exit
(
1
)
except
SSHException
:
except
SSHException
:
log
.
error
(
_
(
"
An error occured during SSH connection, debug with -vv
"
))
log
.
error
(
_
(
"
An error occured during SSH connection, debug with -vv
"
))
raise
raise
...
...
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