我在Laravel上有些挣扎。我想通过ssh连接到远程专用服务器,如果需要,我需要指定此服务器的IP地址,用户名和密码。我有多个专用服务器,我想朗读命令,它们都是在数据库中指定的,在我的情况下,是安装一些游戏服务器。 你有什么想法?如何在控制器中创建连接? 我找到了LaravelCollective,但没有找到定义IP,用户和密码的答案。
代码类似于:
SSH::into('staging')
它看起来像吗?
SSH::into('x.x.x.x', 'root', 'password)
答案 0 :(得分:2)
您需要发布配置文件:
php artisan vendor:publish --provider="Collective\Remote\RemoteServiceProvider"
配置文件位于config/remote.php
上,包含配置远程连接所需的所有选项。连接数组包含按名称键入的服务器列表。
'connections' => [
'production' => [
'host' => '1.2.3.4',
'username' => 'username',
'password' => 'password',
'key' => '',
'keytext' => '',
'keyphrase' => '',
'agent' => '',
'timeout' => 10,
],
'another_server' => [
'host' => '4.3.2.1',
'username' => 'username',
'password' => 'password',
'key' => '',
'keytext' => '',
'keyphrase' => '',
'agent' => '',
'timeout' => 10,
],
],
用法:
SSH::into('production');
SSH::into('another_server');