Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93637587
PhabricatorSSHKeyGenerator.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Nov 30, 08:30
Size
753 B
Mime Type
text/x-php
Expires
Mon, Dec 2, 08:30 (2 d)
Engine
blob
Format
Raw Data
Handle
22678880
Attached To
rPH Phabricator
PhabricatorSSHKeyGenerator.php
View Options
<?php
final
class
PhabricatorSSHKeyGenerator
extends
Phobject
{
public
static
function
assertCanGenerateKeypair
()
{
$binary
=
'ssh-keygen'
;
if
(!
Filesystem
::
resolveBinary
(
$binary
))
{
throw
new
Exception
(
pht
(
'Can not generate keys: unable to find "%s" in PATH!'
,
$binary
));
}
}
public
static
function
generateKeypair
()
{
self
::
assertCanGenerateKeypair
();
$tempfile
=
new
TempFile
();
$keyfile
=
dirname
(
$tempfile
).
DIRECTORY_SEPARATOR
.
'keytext'
;
execx
(
'ssh-keygen -t rsa -N %s -f %s'
,
''
,
$keyfile
);
$public_key
=
Filesystem
::
readFile
(
$keyfile
.
'.pub'
);
$private_key
=
Filesystem
::
readFile
(
$keyfile
);
return
array
(
$public_key
,
$private_key
);
}
}
Event Timeline
Log In to Comment