gitHub CopilotがSSH接続した開発サーバーでは使用できないので、まぁそんなもんなのかと思ってたら実は使えました。
VSCodeの設定ファイル setting.jason に次の行を追加します。
“remote.extensionKind”: { “GitHub.copilot”: [“ui”], }
設定ファイルの開き方は
Cmd + Shift + “p” で Preference: Open User Settings (JASON) です。
Just another Front-end Engineer
gitHub CopilotがSSH接続した開発サーバーでは使用できないので、まぁそんなもんなのかと思ってたら実は使えました。
VSCodeの設定ファイル setting.jason に次の行を追加します。
“remote.extensionKind”: { “GitHub.copilot”: [“ui”], }
設定ファイルの開き方は
Cmd + Shift + “p” で Preference: Open User Settings (JASON) です。
ずっと後回しにしてきていましたが、公式のスクリプトのおかげで移行自体は驚くほど簡単でした。
準備
– yum ではなく dnfを使えるようにインストール
yumでインストールしようとするとロケールがセットできないとかエラーが出るので個別にダウンロードしてインストールします。(参照:https://qiita.com/piyojiro/items/58f9a89120808e1c1e84)
wget http://springdale.math.ias.edu/data/puias/unsupported/7/x86_64/dnf-conf-0.6.4-2.sdl7.noarch.rpm
wget http://springdale.math.ias.edu/data/puias/unsupported/7/x86_64/dnf-0.6.4-2.sdl7.noarch.rpm
wget http://springdale.math.ias.edu/data/puias/unsupported/7/x86_64/python-dnf-0.6.4-2.sdl7.noarch.rpm
yum install python-dnf-0.6.4-2.sdl7.noarch.rpm dnf-0.6.4-2.sdl7.noarch.rpm dnf-conf-0.6.4-2.sdl7.noarch.rpm
– CentoOS7をCentOS8へアップグレードします。
sudo dnf update -y
sudo dnf install http://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/{centos-linux-repos-8-3.el8.noarch.rpm,centos-linux-release-8.5-1.2111.el8.noarch.rpm,centos-gpg-keys-8-3.el8.noarch.rpm} -y
sudo dnf upgrade https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y
sudo dnf clean all
マイグレーション自体は↓
1) スクリプトをダウンロードします
curl -O https://raw.githubusercontent.com/AlmaLinux/almalinux-deploy/master/almalinux-deploy.sh
2)実行
sudo bash almalinux-deploy.sh
3)確認
$ cat /etc/redhat-release
AlmaLinux release 8.10 (Cerulean Leopard)
df -h
で確認
sudo du -ah / | sort -rh | head -n 20
でどのファイルが大きいかを確認できます。
やりたいこと:welcartで運用しているWPサイトAでログインした際にWPサイトBにログインのステータスを表示させたい
1) サイトA site-a.domain.com が動いているサーバーでディレクトリの設定をする
apache2.conf
<Directory /var/www/directory >
Header set Access-Control-Allow-Origin "https://site-b.domain.com" // サイトBでcookieを受け取ることを許可する
Header set Access-Control-Allow-Credentials true
</Directory>
2) サイトAで渡したい情報をcookieへセットします。
functions.php
add_action( 'wp_headers', 'hoge');
function hoge() {
if (usces_is_login()){
$site-a-user-name = usces_the_member_name('return'); // ←welcartのログインユーザー名を取得
}
if (!isset($_COOKIE["site-a-user"])){
setcookie("site-a-user",$site-a-user-name, time() + 86400, "/", "site-b.domain.com"); // ←cookieをセットする時にこのcookieを参照できるサイトを指定する
}
}
・setcookie関数は他の出力よりも前に処理される必要があるとのことなのでwp_headersへフックします
・5つ目のパラメータがcookieを使用できるドメインです
3) サイトB site-b.domain.com でcookieを取得する
function.phpfunction getcookie() {
$site-a-user = $_COOKIE['site-a-user'];
return $loginUser;}
・サイトBからは $_COOKIE でアクセスできます。
UTMのバージョンは4.1.5です。
ubuntu14.04をインストールしようとすると
error:no suitable video mode found
Boot in blind mode
と表示され先に勧めません。
原因はUTMのビデオモードの設定のようです。
デフォルトでは virtio-gpu-gi-pciなどになっていますがこれをVGAなどに変更して再度起動するとエラーを回避できました。
今日はGitLabダウンしてたみたいですね。
まずはダウンロードします
$ sudo curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash
以下、ダウンロード
[sudo] password for contos: [パスワード入力]
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 7016 100 7016 0 0 18477 0 --:--:-- --:--:-- --:--:-- 18511
Detected operating system as centos/7.
Checking for curl...
Detected curl...
Downloading repository file: https://packages.gitlab.com/install/repositories/runner/gitlab-runner/config_file.repo?os=centos&dist=7&source=script
done.
Installing pygpgme to verify GPG signatures...
Failed to set locale, defaulting to C
Loaded plugins: copr, fastestmirror, langpacks
Determining fastest mirrors
epel/x86_64/metalink | 8.1 kB 00:00
* base: mirrors.cat.net
* epel: repo.jing.rocks
* extras: mirrors.cat.net
* remi-safe: cdn.centos.no
* updates: mirrors.cat.net
base | 3.6 kB 00:00:00
copr:copr.fedorainfracloud.org:ngompa:snapcore-el7 | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
nodesource | 2.5 kB 00:00:00
remi-safe | 3.0 kB 00:00:00
runner_gitlab-runner-source/signature | 862 B 00:00:00
Retrieving key from https://packages.gitlab.com/runner/gitlab-runner/gpgkey
Importing GPG key 0x51312F3F:
Userid : "GitLab B.V. (package repository signing key)
Fingerprint: f640 3f65 44a3 8863 daa0 b6e0 3f01 618a 5131 2f3f
From : https://packages.gitlab.com/runner/gitlab-runner/gpgkey
Retrieving key from https://packages.gitlab.com/runner/gitlab-runner/gpgkey/runner-gitlab-runner-4C80FB51394521E9.pub.gpg
Retrieving key from https://packages.gitlab.com/runner/gitlab-runner/gpgkey/runner-gitlab-runner-49F16C5CC3A0F81F.pub.gpg
runner_gitlab-runner-source/signature | 951 B 00:00:01 !!!
updates | 2.9 kB 00:00:00
(1/4): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(2/4): remi-safe/primary_db | 2.5 MB 00:00:00 (3/4): epel/x86_64/primary_db | 7.0 MB 00:00:01
(4/4): updates/7/x86_64/primary_db | 23 MB 00:00:02
runner_gitlab-runner-source/primary | 175 B 00:00:01
Package pygpgme-0.3-9.el7.x86_64 already installed and latest version
Nothing to do
Installing yum-utils...
Failed to set locale, defaulting to C
Loaded plugins: copr, fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.cat.net
* epel: repo.jing.rocks
* extras: mirrors.cat.net
* remi-safe: cdn.centos.no
* updates: mirrors.cat.net
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
Nothing to do
Generating yum cache for runner_gitlab-runner...
Failed to set locale, defaulting to C
Importing GPG key 0x51312F3F:
Userid : "GitLab B.V. (package repository signing key)
Fingerprint: f640 3f65 44a3 8863 daa0 b6e0 3f01 618a 5131 2f3f
From : https://packages.gitlab.com/runner/gitlab-runner/gpgkey
Generating yum cache for runner_gitlab-runner-source...
Failed to set locale, defaulting to C
The repository is setup! You can now install packages.
$
インストールできるよと言われているのでインストールします
$ sudo yum install -y gitlab-runner
↓こんな感じでインストール始まりました
Failed to set locale, defaulting to C
Loaded plugins: copr, fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.cat.net
* epel: repo.jing.rocks
* extras: mirrors.cat.net
* remi-safe: cdn.centos.no
* updates: mirrors.cat.net
Resolving Dependencies
--> Running transaction check
---> Package gitlab-runner.x86_64 0:16.4.1-1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================
Installing:
gitlab-runner x86_64 16.4.1-1 runner_gitlab-runner 461 M
Transaction Summary
===============================================================================================================================================
Install 1 Package
Total download size: 461 M
Installed size: 502 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/runner_gitlab-runner/packages/gitlab-runner-16.4.1-1.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 6ba75a4e: NOKEY==================-] 11 MB/s | 460 MB 00:00:00 ETA
Public key for gitlab-runner-16.4.1-1.x86_64.rpm is not installed
gitlab-runner-16.4.1-1.x86_64.rpm | 461 MB 00:00:44
Retrieving key from https://packages.gitlab.com/runner/gitlab-runner/gpgkey
Importing GPG key 0x51312F3F:
Userid : "GitLab B.V. (package repository signing key)
Fingerprint: f640 3f65 44a3 8863 daa0 b6e0 3f01 618a 5131 2f3f
From : https://packages.gitlab.com/runner/gitlab-runner/gpgkey
Retrieving key from https://packages.gitlab.com/runner/gitlab-runner/gpgkey/runner-gitlab-runner-4C80FB51394521E9.pub.gpg
Importing GPG key 0x35DFA027:
Userid : "GitLab, Inc.
Fingerprint: 09e5 7083 f34c ca94 d541 bc58 a674 bf81 35df a027
From : https://packages.gitlab.com/runner/gitlab-runner/gpgkey/runner-gitlab-runner-4C80FB51394521E9.pub.gpg
Retrieving key from https://packages.gitlab.com/runner/gitlab-runner/gpgkey/runner-gitlab-runner-49F16C5CC3A0F81F.pub.gpg
Importing GPG key 0x6BA75A4E:
Userid : "GitLab, Inc.
Fingerprint: 931d a69c fa3a febb c97d aa8c 6c57 c29c 6ba7 5a4e
From : https://packages.gitlab.com/runner/gitlab-runner/gpgkey/runner-gitlab-runner-49F16C5CC3A0F81F.pub.gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : gitlab-runner-16.4.1-1.x86_64 [####################################################################################################################### Installing : gitlab-runner-16.4.1-1.x86_64 [######################################################################################################################## Installing : gitlab-runner-16.4.1-1.x86_64 [########################################################################################################################## Installing : gitlab-runner-16.4.1-1.x86_64 1/1
GitLab Runner: creating gitlab-runner...
Home directory skeleton not used
Runtime platform arch=amd64 os=linux pid=17698 revision=d89a789a version=16.4.1
gitlab-runner: the service is not installed
Runtime platform arch=amd64 os=linux pid=17703 revision=d89a789a version=16.4.1
gitlab-ci-multi-runner: the service is not installed
Runtime platform arch=amd64 os=linux pid=17715 revision=d89a789a version=16.4.1
Runtime platform arch=amd64 os=linux pid=17763 revision=d89a789a version=16.4.1
INFO: Docker installation not found, skipping clear-docker-cache
Verifying : gitlab-runner-16.4.1-1.x86_64 1/1
Installed:
gitlab-runner.x86_64 0:16.4.1-1
Complete!
$
確認してみます
$ sudo gitlab-runner --version
[sudo] password for centos: [パスワード]
Version: 16.4.1
Git revision: d89a789a
Git branch: 16-4-stable
GO version: go1.20.5
Built: 2023-10-06T01:26:25+0000
OS/Arch: linux/amd64
$
$ sudo gitlab-runner status
[sudo] password for centos: [パスワード]
Runtime platform arch=amd64 os=linux pid=18832 revision=d89a789a version=16.4.1
gitlab-runner: Service is running
$
インストールはされたっぽい
次は登録します
gitlabの「設定」→「CI/CD]を開いて「Runner」を展開します。
「新規プロジェクトRunner」をクリックします
新規作成画面になりますので
タグに何か入れて「作成」をクリックします
するとrunnerが作成されます
このトークンをクリップボードにコピーしておきます
$ sudo gitlab-runner register
[sudo] password for centos:[パスワード入力]
Runtime platform arch=amd64 os=linux pid=19417 revision=d89a789a version=16.4.1
Running in system-mode.
gitlabのインスタンスのURLを求められます。
言われている通りhttps://gitlab.com/ と入力します。
Enter the GitLab instance URL (for example, https://gitlab.com/):
https://gitlab.com/
するとトークンを求められるので、先ほど作成したトークンをペーストします。
Enter the registration token:
tokenTOKENtokenTOKENtokenTOKEN
Verifying runner... is valid runner=RunnerIDppoi
こんどはRunnerに名前をつけてくださいと言われます。
my-runnerとか入れておきます。
Enter a name for the runner. This is stored only in the local config.toml file:
: my-runner
実行環境を決めてくださいと言われます。
shellにしときます。
Enter an executor: virtualbox, docker-autoscaler, docker+machine, custom, docker, docker-windows, parallels, ssh, kubernetes, shell, instance:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
Configuration (with the authentication token) was saved in "/etc/gitlab-runner/config.toml"
先ほどの「設定」→「CI/CD」 Runnerを展開すると登録したRunnerを見ることができます。
GitLab-CI/CD でssh接続しようとすると
Pseudo-terminal will not be allocated because stdin is not a terminal.
エラーが表示される
解決方法:
ssh -tt オプションをつける
ttとは “text terminal” のことらしい
pseudo とは “擬似”
stdin とは標準入力のこと
“標準入力はターミナルではないので擬似ターミナルは割り当てられません”ということらしい
-tt オプションで強制的に割り当てることができるそうです。
Ubuntuに限り、最初からバンドルされない仕様になっているそうです。
sudo apt-get install php-xml
でインストール
/etc/ssh/sshd_configの最初の方にある
Port 22
の次あたりに
Port [使いたいポート番号]
追記する
あと最後に
AllowUsers [ユーザー名] [ユーザー名]
sshdを再起動する
あとファイアウォールの設定をする
新しいポート番号でログインできることを確認してから
sshd_configの
Port 22
をコメントアウトする
指定したユーザー以外でssh接続しようとするとパスワード聞かれた後で(パスワード合ってても) Permission denied と言われます。
仮想サーバーをインストールし直してローカルマシンから接続しようとするとHost Key Verification Failedと表示されてssh接続できない
“IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!” (誰かが何か厄介なことをしている可能性があります!)😅
解決方法は
ssh-keygen -R 127.0.0.1
~/.ssh/known_hosts の何かが変更されて接続できるようになります。