Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F35156001
PhabricatorSSHKeyGenerator.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
753 B
Subscribers
None
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
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Feb 2, 8:11 AM (1 d, 11 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
be/5b/d9f54f3a39d95e6c355661a50b53
Attached To
rPHAB Phabricator
Event Timeline
Log In to Comment