phpseclib - Can I connect using username, key and password (not a key passphrase)(phpseclib - 我可以使用用户名、密钥和密码(不是密钥密码)进行连接吗)
问题描述
Apologies if I have missed this in the documentation but is it possible to connect to an SFTP server with a private key and a password (not a passphrase for my private key).
The examples show username/password, username/key and username/key/key passphrase authentication types.
When connecting via the command line I would get this prompt for my password...
user@x.x.x.x's password:
Hopefully this library can handle this?
Otherwise are there any other PHP based solutions that might support username/key and server password authentication? I'm quite flexible here and can install modules if need be.
EDIT
Thanks for the help so far...
I had tried what you mentioned Neubert but this didn't seem to work.
And to verify what is necessary to connect to the server I tested this on the command line.
sftp key user@ip
- Prompted for password as expected
sftp user@ip
- Prompted for password but when entered correctly told I am "authenticated with partial success".
I think the permission on directories and keys should be fine if I can get in using key and then password.
I am starting to think this library doesn't support what I need.
phpseclib supports multi factor authentication. Here's an example of how to do it:
<?php
include('Net/SSH2.php');
include('Crypt/RSA.php')
$rsa = new Crypt_RSA();
$rsa->loadKey(file_get_contents('/path/to/key.pem'));
$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'pass1', $rsa)) {
exit('Login failed');
}
// this does the same thing as the above
//if (!$ssh->login($username, 'pass1') && !$ssh->login('username', $rsa)) {
// exit('Login failed');
/
本文标题为:phpseclib - 我可以使用用户名、密钥和密码(不是密钥密码)进行连接吗
基础教程推荐
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01