Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
c0cef9e0
Commit
c0cef9e0
authored
May 05, 2013
by
Brad Morgan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added username and password auth for ssh
parent
7261d983
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
17 deletions
+41
-17
src/transports/ssh.c
+41
-17
No files found.
src/transports/ssh.c
View file @
c0cef9e0
...
...
@@ -224,6 +224,43 @@ static int git_ssh_extract_url_parts(
return
0
;
}
static
int
_git_ssh_authenticate_session
(
LIBSSH2_SESSION
*
session
,
const
char
*
user
,
git_cred
*
cred
)
{
int
rc
;
do
{
switch
(
cred
->
credtype
)
{
case
GIT_CREDTYPE_USERPASS_PLAINTEXT
:
{
git_cred_userpass_plaintext
*
c
=
(
git_cred_userpass_plaintext
*
)
cred
;
rc
=
libssh2_userauth_password
(
session
,
c
->
username
,
c
->
password
);
break
;
}
case
GIT_CREDTYPE_SSH_KEYFILE_PASSPHRASE
:
{
git_cred_ssh_keyfile_passphrase
*
c
=
(
git_cred_ssh_keyfile_passphrase
*
)
cred
;
rc
=
libssh2_userauth_publickey_fromfile
(
session
,
user
,
c
->
publickey
,
c
->
privatekey
,
c
->
passphrase
);
break
;
}
default:
rc
=
-
1
;
}
}
while
(
LIBSSH2_ERROR_EAGAIN
==
rc
||
LIBSSH2_ERROR_TIMEOUT
==
rc
);
return
rc
;
}
static
int
_git_ssh_setup_conn
(
ssh_subtransport
*
t
,
const
char
*
url
,
...
...
@@ -244,7 +281,7 @@ static int _git_ssh_setup_conn(
if
(
!
git__prefixcmp
(
url
,
prefix_ssh
))
{
url
=
url
+
strlen
(
prefix_ssh
);
if
(
gitno_extract_url_parts
(
&
host
,
&
port
,
&
user
,
&
pass
,
url
,
default_port
)
<
0
)
return
-
1
;
goto
on_error
;
}
else
{
if
(
git_ssh_extract_url_parts
(
&
host
,
&
user
,
url
)
<
0
)
goto
on_error
;
...
...
@@ -270,8 +307,6 @@ static int _git_ssh_setup_conn(
user
=
git__strdup
(
default_user
);
}
git_cred_ssh_keyfile_passphrase
*
cred
=
(
git_cred_ssh_keyfile_passphrase
*
)
t
->
cred
;
LIBSSH2_SESSION
*
session
=
libssh2_session_init
();
if
(
!
session
)
goto
on_error
;
...
...
@@ -288,20 +323,9 @@ static int _git_ssh_setup_conn(
libssh2_trace
(
session
,
0x1FF
);
libssh2_session_set_blocking
(
session
,
1
);
do
{
rc
=
libssh2_userauth_publickey_fromfile_ex
(
session
,
user
,
strlen
(
user
),
cred
->
publickey
,
cred
->
privatekey
,
cred
->
passphrase
);
}
while
(
LIBSSH2_ERROR_EAGAIN
==
rc
||
LIBSSH2_ERROR_TIMEOUT
==
rc
);
if
(
0
!=
rc
)
{
goto
on_error
;
}
if
(
_git_ssh_authenticate_session
(
session
,
user
,
t
->
cred
)
<
0
)
{
goto
on_error
;
}
LIBSSH2_CHANNEL
*
channel
=
NULL
;
do
{
...
...
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