text Zone.ee SSH配置生成器
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text Zone.ee SSH配置生成器相关的知识,希望对你有一定的参考价值。
<?php
$userName = '--';
$apiKey = '--';
$dir = getenv('HOME') . '/proge';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.zone.eu/v2/vserver');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, $userName . ":" . $apiKey);
$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
curl_close ($ch);
$vservers = json_decode($result, true);
$hostTemplate = '
Host {{HOST}}
HostName {{HOST}}
ForwardAgent yes
User {{USER}}
';
$sshConfig = '';
$sshFsConfig = '';
foreach ($vservers as $vserver) {
$thisTemplate = $hostTemplate;
$thisTemplate = str_replace('{{HOST}}', $vserver['name'], $thisTemplate);
$thisTemplate = str_replace('{{USER}}', $vserver['group'], $thisTemplate);
$sshConfig .= $thisTemplate;
$sshFsDir = $dir . '/' . $vserver['name'];
if (!file_exists($sshFsDir)) {
mkdir($sshFsDir);
}
$sshFsConfig .= 'mount_' . str_replace('.', '_', $vserver['name']) . ' () {' . PHP_EOL;
$sshFsConfig .= ' sshfs -o follow_symlinks ' . $vserver['group'] . '@' . $vserver['name'] . ': ' . $sshFsDir . PHP_EOL;
$sshFsConfig .= '}' . PHP_EOL . PHP_EOL;
}
//generate ssh config
file_put_contents('functions.sh', $sshFsConfig);
//generate sshfs mount functions
file_put_contents('ssh-config.txt', $sshConfig);
以上是关于text Zone.ee SSH配置生成器的主要内容,如果未能解决你的问题,请参考以下文章
text 生成新的SSH密钥
text 在Mac中手动生成SSH密钥
text ssh配置
text SSH配置文件
text ssh配置
text ssh配置