E
E
Evgeny Antipov2018-08-21 17:32:13
PHP
Evgeny Antipov, 2018-08-21 17:32:13

SSH key generation?

I do not understand how to create and save a key using the standard ssh2 lib.
From the docks:

$ssh = ssh2_connect("127.0.0.1", "22");
        ssh2_auth_password($ssh, "root", "1234567890");
        $pkey = ssh2_publickey_init($ssh);

        $keyblob = base64_decode(
            "AAAAB3NzaC1yc2EAAAABIwAAAIEA5HVt6VqSGd5PTrLRdjNONxXH1tVFGn0
            Bd26BF0aCP9qyJRlvdJ3j4WBeX4ZmrveGrjMgkseSYc4xZ26sDHwfL351xj
            zaLpipu\BGRrw17mWVBhuCExo476ri5tQFzbTc54VEHYckxQ16CjSTibI5X
            69GmnYC9PNqEYq/1TP+HF10="
        );

        $result = ssh2_publickey_add($ssh, 'ssh-rsa', $keyblob, false, array('comment' => "John's Key"));
        var_dump($pkey); // NULL
        var_dump($result); // bool(false)

What for $keyblob? Where did he come from? What should happen in ssh2_publickey_init()?
Where are these keys stored on the server (Debian 9.5)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2018-08-21
@saboteur_kiev

Create a key with the appropriate utility.
For example console ssh-keygen or puttygen from putty.org
ssh2 is either a client, not a key generator.

A
Antonio Solo, 2018-08-21
@solotony

in order to "create and save the key" you need to use the appropriate utilities.
and php-shny ssh is actually an ssh client

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question