総数:19 今日:1 昨日:0

もくじ

install SSH Server on Ubuntu 18.04.1

参考URL https://linuxconfig.org/how-to-install-ssh-server-on-ubuntu-16-04-xenial-linux

install SSH Server

$ sudo apt -y install ssh
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
  ncurses-term openssh-server openssh-sftp-server ssh-import-id
提案パッケージ:
  molly-guard monkeysphere rssh ssh-askpass
以下のパッケージが新たにインストールされます:
  ncurses-term openssh-server openssh-sftp-server ssh ssh-import-id
アップグレード: 0 個、新規インストール: 5 個、削除: 0 個、保留: 168 個。
642 kB のアーカイブを取得する必要があります。
この操作後に追加で 5,422 kB のディスク容量が消費されます。
続行しますか? [Y/n] Y
取得:1 http://jp.archive.ubuntu.com/ubuntu bionic/main amd64 openssh-sftp-server amd64 1:7.6p1-4 [45.5 kB]
取得:2 http://jp.archive.ubuntu.com/ubuntu bionic/main amd64 openssh-server amd64 1:7.6p1-4 [332 kB]
取得:3 http://jp.archive.ubuntu.com/ubuntu bionic/main amd64 ssh all 1:7.6p1-4 [5,188 B]
取得:4 http://jp.archive.ubuntu.com/ubuntu bionic-updates/main amd64 ncurses-term all 6.1-1ubuntu1.18.04 [248 kB]
取得:5 http://jp.archive.ubuntu.com/ubuntu bionic-updates/main amd64 ssh-import-id all 5.7-0ubuntu1.1 [10.9 kB]
642 kB を 0秒 で取得しました (2,224 kB/s) 
パッケージを事前設定しています ...
以前に未選択のパッケージ openssh-sftp-server を選択しています。
(データベースを読み込んでいます ... 現在 150354 個のファイルとディレクトリがインストールされています。)
.../openssh-sftp-server_1%3a7.6p1-4_amd64.deb を展開する準備をしています ...
openssh-sftp-server (1:7.6p1-4) を展開しています...
以前に未選択のパッケージ openssh-server を選択しています。
.../openssh-server_1%3a7.6p1-4_amd64.deb を展開する準備をしています ...
openssh-server (1:7.6p1-4) を展開しています...
以前に未選択のパッケージ ssh を選択しています。
.../ssh_1%3a7.6p1-4_all.deb を展開する準備をしています ...
ssh (1:7.6p1-4) を展開しています...
以前に未選択のパッケージ ncurses-term を選択しています。
.../ncurses-term_6.1-1ubuntu1.18.04_all.deb を展開する準備をしています ...
ncurses-term (6.1-1ubuntu1.18.04) を展開しています...
以前に未選択のパッケージ ssh-import-id を選択しています。
.../ssh-import-id_5.7-0ubuntu1.1_all.deb を展開する準備をしています ...
ssh-import-id (5.7-0ubuntu1.1) を展開しています...
ncurses-term (6.1-1ubuntu1.18.04) を設定しています ...
ufw (0.35-5) のトリガを処理しています ...
ureadahead (0.100.0-20) のトリガを処理しています ...
openssh-sftp-server (1:7.6p1-4) を設定しています ...
systemd (237-3ubuntu10.3) のトリガを処理しています ...
man-db (2.8.3-2) のトリガを処理しています ...
ssh-import-id (5.7-0ubuntu1.1) を設定しています ...
openssh-server (1:7.6p1-4) を設定しています ...

Creating config file /etc/ssh/sshd_config with new version
Creating SSH2 RSA key; this may take some time ...
2048 SHA256:cLhdyS6T2FHIFVs2HpNmOPHxYnEtcq9myKG/A0h9PS8 root@ubdt18041 (RSA)
Creating SSH2 ECDSA key; this may take some time ...
256 SHA256:5wLpCfANsugRzLMpfuukGQs3bs8m+IYofvqr9RpkAzw root@ubdt18041 (ECDSA)
Creating SSH2 ED25519 key; this may take some time ...
256 SHA256:FGaXoCFzTq/XmOzBHzAbjNqo6YxHRECFGiNadUYWblU root@ubdt18041 (ED25519)
Created symlink /etc/systemd/system/sshd.service → /lib/systemd/system/ssh.service.
Created symlink /etc/systemd/system/multi-user.target.wants/ssh.service → /lib/systemd/system/ssh.service.
ssh (1:7.6p1-4) を設定しています ...
ureadahead (0.100.0-20) のトリガを処理しています ...
systemd (237-3ubuntu10.3) のトリガを処理しています ...
ufw (0.35-5) のトリガを処理しています ...

start the SSH server using the following command

$ sudo service ssh start

To automatically start your SSH server after reboot

$ sudo systemctl enable ssh
Synchronizing state of ssh.service with SysV init with /lib/systemd/systemd-sysv-install.
Executing /lib/systemd/systemd-sysv-install enable ssh

UbuntuからWindowsの共有フォルダを自動マウントする

下記を参考に操作するWindowsの共有フォルダを自動マウントするようにしておく
http://foxtail.lv9.org/wiki/doc/pukiwiki-1_5_1_utf8/index.php?mount%20command#o9dce617

Installation

~$ wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
OK
~$ sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
~$ sudo apt update
ヒット:1 http://jp.archive.ubuntu.com/ubuntu bionic InRelease
ヒット:2 http://jp.archive.ubuntu.com/ubuntu bionic-updates InRelease                                    
ヒット:3 http://jp.archive.ubuntu.com/ubuntu bionic-backports InRelease                                  
ヒット:4 http://security.ubuntu.com/ubuntu bionic-security InRelease                                           
無視:5 http://pkg.jenkins.io/debian-stable binary/ InRelease  
取得:6 http://pkg.jenkins.io/debian-stable binary/ Release [2,042 B]
取得:7 http://pkg.jenkins.io/debian-stable binary/ Release.gpg [181 B]
取得:8 http://pkg.jenkins.io/debian-stable binary/ Packages [13.6 kB]
15.8 kB を 1秒 で取得しました (11.6 kB/s)
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています       
状態情報を読み取っています... 完了
アップグレードできるパッケージが 168 個あります。表示するには 'apt list --upgradable' を実行してください。

方法1 apt-getでインストールする

~$ sudo apt-get install jenkins
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
  daemon
以下のパッケージが新たにインストールされます:
  daemon jenkins
アップグレード: 0 個、新規インストール: 2 個、削除: 0 個、保留: 4 個。
69.0 MB のアーカイブを取得する必要があります。
この操作後に追加で 70.1 MB のディスク容量が消費されます。
続行しますか? [Y/n] Y
取得:1 http://jp.archive.ubuntu.com/ubuntu xenial/universe amd64 daemon amd64 0.6.4-1 [98.2 kB]
取得:2 http://pkg.jenkins.io/debian-stable binary/ jenkins 2.19.1 [68.9 MB]
69.0 MB を 10秒 で取得しました (6,299 kB/s)                                                                                                                                                   
以前に未選択のパッケージ daemon を選択しています。
(データベースを読み込んでいます ... 現在 190132 個のファイルとディレクトリがインストールされています。)
.../daemon_0.6.4-1_amd64.deb を展開する準備をしています ...
daemon (0.6.4-1) を展開しています...
以前に未選択のパッケージ jenkins を選択しています。
.../jenkins_2.19.1_all.deb を展開する準備をしています ...
jenkins (2.19.1) を展開しています...
man-db (2.7.5-1) のトリガを処理しています ...
systemd (229-4ubuntu10) のトリガを処理しています ...
ureadahead (0.100.0-19) のトリガを処理しています ...
daemon (0.6.4-1) を設定しています ...
jenkins (2.19.1) を設定しています ...
systemd (229-4ubuntu10) のトリガを処理しています ...
ureadahead (0.100.0-19) のトリガを処理しています ...

バージョンを確認

方法2 古いバージョンの場合は debパッケージを取得してインストールする

https://pkg.jenkins.io/debian-stable/ からインストールしたいバージョンを探す 例 2.138.2 をインストールしたい場合

~$ wget https://pkg.jenkins.io/debian-stable/binary/jenkins_2.138.2_all.deb
--2018-10-15 22:37:28--  https://pkg.jenkins.io/debian-stable/binary/jenkins_2.138.2_all.deb
pkg.jenkins.io (pkg.jenkins.io) をDNSに問いあわせています... 52.202.51.185
pkg.jenkins.io (pkg.jenkins.io)|52.202.51.185|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 302 Found
場所: https://prodjenkinsreleases.blob.core.windows.net/debian-stable/jenkins_2.138.2_all.deb [続く]
--2018-10-15 22:37:29--  https://prodjenkinsreleases.blob.core.windows.net/debian-stable/jenkins_2.138.2_all.deb
prodjenkinsreleases.blob.core.windows.net (prodjenkinsreleases.blob.core.windows.net) をDNSに問いあわせています... 104.208.128.30
prodjenkinsreleases.blob.core.windows.net (prodjenkinsreleases.blob.core.windows.net)|104.208.128.30|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 75496730 (72M) [application/x-debian-package]
`jenkins_2.138.2_all.deb' に保存中

jenkins_2.138.2_all.deb          100%[=======================================================>]  72.00M   451KB/s    時間 2m 59s

2018-10-15 22:40:29 (412 KB/s) - `jenkins_2.138.2_all.deb' へ保存完了 [75496730/75496730]
~$ sudo apt install daemon
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下のパッケージが新たにインストールされます:
  daemon
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 168 個。
99.5 kB のアーカイブを取得する必要があります。
この操作後に追加で 288 kB のディスク容量が消費されます。
取得:1 http://jp.archive.ubuntu.com/ubuntu bionic/universe amd64 daemon amd64 0.6.4-1build1 [99.5 kB]
99.5 kB を 0秒 で取得しました (598 kB/s)
以前に未選択のパッケージ daemon を選択しています。
(データベースを読み込んでいます ... 現在 153171 個のファイルとディレクトリがインストールされています。)
.../daemon_0.6.4-1build1_amd64.deb を展開する準備をしています ...
daemon (0.6.4-1build1) を展開しています...
man-db (2.8.3-2) のトリガを処理しています ...
daemon (0.6.4-1build1) を設定しています ...
~$ sudo dpkg -i jenkins_2.138.2_all.deb
以前に未選択のパッケージ jenkins を選択しています。
(データベースを読み込んでいます ... 現在 153179 個のファイルとディレクトリがインストールされています。)
jenkins_2.138.2_all.deb を展開する準備をしています ...
jenkins (2.138.2) を展開しています...
jenkins (2.138.2) を設定しています ...
ureadahead (0.100.0-20) のトリガを処理しています ...
systemd (237-3ubuntu10.3) のトリガを処理しています ...

/etc/default/jenkinsの編集

~$ sudo gvim -f /etc/default/jenkins

編集例

~$ colordiff -pu /etc/default/jenkins.default /etc/default/jenkins
--- /etc/default/jenkins.default	2016-10-05 00:20:48.000000000 +0900
+++ /etc/default/jenkins	2016-10-10 18:17:07.879767718 +0900
@@ -10,6 +10,7 @@ JAVA=/usr/bin/java
 JAVA_ARGS="-Djava.awt.headless=true"  # Allow graphs etc. to work even when an X server is present
 #JAVA_ARGS="-Xmx256m"
 #JAVA_ARGS="-Djava.net.preferIPv4Stack=true" # make jenkins listen on IPv4 address
+JAVA_ARGS="-Dfile.encoding=utf-8" # avoid garbled characters in Git Plugin
 
 PIDFILE=/var/run/$NAME/$NAME.pid
 
@@ -54,8 +55,8 @@ MAXOPENFILES=8192
 # UMASK=027
 
 # port for HTTP connector (default 8080; disable with -1)
-HTTP_PORT=8080
-
+#HTTP_PORT=8080
+HTTP_PORT=4000
 
 # servlet context, important if you want to use apache proxying  
 PREFIX=/$NAME
@@ -69,4 +70,4 @@ PREFIX=/$NAME
 # --webroot=~/.jenkins/war
 # --prefix=$PREFIX
 
-JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT"
+JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT --prefix=/jenkins"

restart jenkins

~$ sudo service jenkins restart
 * Restarting Jenkins Continuous Integration Server jenkins                                                                                                                         

getting start

ブラウザで接続

http://<hostname>:<port>/jenkins/

下記ファイルの初期パスワードを Administrator password エディットボックスへペースト

/var/lib/jenkins/secrets/initialAdminPassword

画面右下の continue ボタンを選択する

Install Suggested Plugins ボタンを選択する

First Admin User 情報を入力する

Username: jenkins
Password: プリセットされている
Confirm password: 同じのを入力する
Full name: <your name>
E-mail address: <your email address>

Continue as admin を選択する

Start using Jenkins ボタンを選択する

Pluginを設定する

ブラウザで接続

http://<hostname>:<port>/jenkins/

ログインする

Username: admin
Password: <Administrator password>

画面左の Manage Jenkins を選択

Manage Plugins を選択

Availableタブ を選択

下記のプラグインをインストールする

プラグイン説明備考
Javadoc PluginThis plugin adds Javadoc support to Jenkins.その他 (website)
Filesystem Trigger Plug-inFSTrigger provides polling mechanisms to monitor a file system and trigger a build if a file or a set of files have changed.ビルドトリガ
Shelve Project PluginThis plugin lets you shelve projects so that they can easily be resurrected.その他 (website)
ユーザーインタフェース
Translation Assistance pluginThis plugin adds an additional dialog box in every page, which enables people to contribute localizations for the messages they are seeing in the current pageユーザーインタフェース
Maven Integration pluginThis plugin provides an advanced integration for Maven 2/3 projects.ビルドツール
Job Configuration History PluginSaves copies of all job and system configurations.その他 (website)
ユーザーインタフェース
Parameterized Trigger pluginThis plugin lets you trigger new builds when your build has completed, with various ways of specifying parameters for the new build.その他 (website)
CVS Plug-inThis bundled plugin integrates Jenkins with CVS version control system.ソース管理システム
Copy Artifact PluginThis bundled plugin integrates Jenkins with CVS version control system.ソース管理システム
Join pluginThis plugin allows a job to be run after all the immediate downstream jobs have completed.ビルドトリガ
Files Found TriggerBuild trigger that polls one or more directories and starts a build if certain files are found within those directories.ビルドトリガ
disk-usage pluginThis plugin records disk usage.ビルドレポート
SSH Agent PluginThis plugin allows you to provide SSH credentials to builds via a ssh-agent in Jenkins.その他 (website)
RebuilderThis plug-in allows the user to _rebuild_ a _parametrized build_ without entering the _parameters_ again.It will also allow the user to edit the parameters before rebuilding.その他 (website)
Gerrit TriggerThis plugin integrates Jenkins to Gerrit code review for triggering builds when a "patch set" is created.ビルドトリガ
ThinBackupThis plugin simply backs up the global and job specific configurations (not the archive or the workspace).その他 (website)
Mask Passwords PluginThis plugin allows masking passwords that may appear in the consoleその他 (website)
ビルドラッパー
Build Trigger Badge PluginThis plugin displays icon(s) representing the cause(s) of a build directly in the build history. It lets you quickly know which cause triggered a build.ユーザーインタフェース
jQuery pluginThis plugin is a library plugin for other plugins to share common jQuery. It also allows users to use jQuery on each view descriptions.Library plugins (for use by other plugins)
Node and Label parameter pluginThis plugin adds two new parameter types to job configuration - node and label, this allows to dynamically select the node where a job/project should be executed.Agent Launchers and Controllers
Build Parameters
ビルドトリガ
Build Pipeline PluginThis plugin provides a _Build Pipeline View_ of upstream and downstream connected jobs that typically form a build pipeline.  In addition, it offers the ability to define manual triggers for jobs that require intervention prior to execution, e.g. an approval process outside of Jenkins.ビルドツール
ビルド後のアクション
ユーザーインタフェース
Publish Over CIFSSend build artifacts to a windows share (CIFS/SMB/samba)成果物のアップロード
Selenium Auto Exec Server(AES) pluginThis plugin is for continuous regression test by Selenium Auto Exec Server (AES).ビルドツール
ビルドレポート
Mercurial pluginThis plugin integrates the Mercurial version control system with Jenkins.ソース管理システム
Associated Files PluginThis plugin allows for marking files or directories outside of Jenkins as related to a build.ビルド後のアクション
File System SCMUse File System as SCM.ソース管理システム
Role-based Authorization StrategyAdds a new role-based strategy to manage users' permissions.Security
認証/ユーザー管理
Safe RestartThis plugin allows you to restart Jenkins safely.

グローバルセキュリティの設定

参考URL http://qiita.com/west-hiroaki/items/410a76c96ad57c8cb547

「Jenkinsの管理」 を選択

「グローバルセキュリティの設定」 を選択

「セキュリティを有効化」をチェック

「Jenkinsのユーザーデータベース」をチェック

「ユーザーにサインアップを許可」のチェックをはずす

「Role-Based Strategy」をチェック

「保存」を選択

Jenkinsにログインするユーザーの作成/削除/変更

adminでJenkinsにログインする

「Jenkinsの管理」 を選択する

「ユーザーの管理」 を選択する

画面左側の 「ユーザー作成」 を選択する

新規ユーザの情報を入力する

ユーザー名: john
パスワード: john
パスワードの確認: john
フルネーム: John Smith
メールアドレス: john@smith

「ユーザー作成」 ボタンを選択する

Jenkinsにログインするユーザーの権限設定

権限の作成

プラグインをインストールした直後は、全てのアクションが可能なadmin権限しか無いので、その他の権限を作成します。
例として、閲覧と既存ジョブが実行可能なoperator権限を作成します。

「Jenkinsの管理」 を選択

「Manage and Assign Roles」 を選択

「Manage Roles」 を選択

「Global roles」の「Role to add」に「operator」と入力してAddボタンを押す。

以下の権限にチェックする。

「Save」ボタンを押して権限設定を反映させる。

ユーザーに権限を付与

作成したユーザーと権限を紐付けます。

「Jenkinsの管理」 を選択

「Manage and Assign Roles」 を選択

「Assign Roles」 を選択

「User/group to add」に「john」と入力して、Addボタンを押す。

Global rolesの各ユーザーに権限を付与する。

「Save」ボタンを押して権限設定を反映させる。

Jenkinsがjob実行でsudoを使用しても、パスワード入力を省略できるようにする

Jenkinsのjob実行processを調査する

job作成 confirm_processes

# $HOMEを確認する
echo "HOME: ${HOME}"
# current directoryを確認する
work_dir=`pwd`
echo "work_dir: ${work_dir}"
# process idを確認する
echo "pid of this job : $$"
pid_of_this_job="$$"
# 指定したprocess idのprocessの情報を確認する
ps auxcf | grep -i --color -e "^USER\|${pid_of_this_job}"

job実行

実行結果 USERは jenkins だ。$HOMEは /var/lib/jenkins だ。

ビルドします。 ワークスペース: /var/lib/jenkins/workspace/confirm_processes
[confirm_processes] $ /bin/sh -xe /tmp/hudson1474396497236908427.sh
+ echo HOME: /var/lib/jenkins
HOME: /var/lib/jenkins
+ pwd
+ work_dir=/var/lib/jenkins/workspace/confirm_processes
+ echo work_dir: /var/lib/jenkins/workspace/confirm_processes
work_dir: /var/lib/jenkins/workspace/confirm_processes
+ echo pid of this job : 2750
pid of this job : 2750
+ pid_of_this_job=2750
+ ps auxcf
+ grep -i --color -e ^USER\|2750
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
jenkins   2750  0.0  0.0   4508   708 ?        S    11:16   0:00      \_ sh
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Notifying upstream projects of job completion
Finished: SUCCESS

すべてのコマンドのパスワード入力を省略する

visudoを使ってsudoersファイルを編集

$ sudo visudo

下記を追記する

jenkins ALL=NOPASSWD: ALL

編集後

 1 #
 2 # This file MUST be edited with the 'visudo' command as root.
 3 #
 4 # Please consider adding local content in /etc/sudoers.d/ instead of
 5 # directly modifying this file.
 6 #
 7 # See the man page for details on how to write a sudoers file.
 8 #
 9 Defaults        env_reset
10 Defaults        mail_badpass
11 Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
12 
13 # Host alias specification
14 
15 # User alias specification
16 
17 # Cmnd alias specification
18 
19 # User privilege specification
20 root    ALL=(ALL:ALL) ALL
21 jenkins ALL=NOPASSWD: ALL
22 # Members of the admin group may gain root privileges
23 %admin ALL=(ALL) ALL
24 
25 # Allow members of group sudo to execute any command
26 %sudo   ALL=(ALL:ALL) ALL
27 
28 # See sudoers(5) for more information on "#include" directives:
29 
30 #includedir /etc/sudoers.d

システムの設定

Jenkinsの位置

Jenkins URLhttp://<jenkins_host>:<port>/jenkins/

nodeの設定 slave node側

nodeのhostname確認

$ cat /etc/hostname 
ubdt12045

jenkins slave用のuserを作成する

user名: jenkins_slave_<hostname> にしよう

# adduser jenkins_slave_ubdt12045

sudoグループに追加

# gpasswd -a jenkins_slave_ubdt12045 sudo

すべてのコマンドのパスワード入力を省略する ubuntu12.04の場合

# visudo

ssh serverをインストール

sudo apt-get install ssh

ssh鍵生成しておく

~$ ssh-keygen -t rsa

パスフレーズは空を指定すること。

nodeの設定 master側

ssh鍵生成しておく

 $ cd ~
~$ ssh-keygen -t rsa

パスフレーズは空を指定すること。
このとき作成される下記のファイル名を変えてはいけない。

.ssh/id_rsa
.ssh/id_rsa.pub

Jenkins->認証情報 画面にて 認証情報の追加 予め作成しておく。あとでNode新規作成時に認証情報として指定する

http://<jenkins_host>:<port>/jenkins/credentials/store/system/domain/_/newCredentials
設定項目設定値
種類「SSHユーザー名と秘密鍵」を選択する
スコープグローバル
ユーザー名jenkins_slave_ubdt12045
秘密鍵「Jenkinsマスター上の~/.sshから」を選択する
パスフレーズ空欄にする(ssh-keygen実行時のパスフレーズを指定する)
ID空欄にする(あとで自動的に決定される)
説明

ユーザー名として指定した、jenkins_slave_ubdt12045 という名前の認証情報が作成される。

まずはスレーブを作ってみる

新規ノード作成画面にて

http://<hostname>:<port>/jenkins/computer/

ノード編集画面にて

http://<hostname>:<port>/jenkins/computer/createItem
設定項目設定値
ノード名ubdt12045
説明
同時ビルド数1
リモートFSルート/home/jenkins_slave_ubdt12045
ラベルONE_OF_BUILD_PCs ONE_OF_UBUNTU_1404_PCs (例)slave nodeの特性を表す文字列を空白文字で区切る形式)
用途このマシーンを特定ジョブ専用にする
起動方法SSH経由でUnixマシンのスレーブエージェントを起動
ホストスレーブマシンのipアドレス
認証情報jenkins_slave_ubdt12045 という名前の認証情報 を選択 でとりあえず作成
Host Key Verification StrategyKnown hosts file Verification Strategy を選択

jenkins ユーザーになって、一度はslaveへssh接続しておく

 $ sudo su jenkins
 $ cd ~
~$ pwd
/var/lib/jenkins
~$ ssh jenkins_slave_ubdt12045@<slave ip address>

jenkins ユーザー のままで、slave側をknown_hostを取り込んでおく

master側の公開鍵をslave側へ渡す

$ scp -P 22 ~/.ssh/id_rsa.pub jenkins_slave_ubdt12045@<slave ip address>:~/.ssh/authorized_keys

master側の公開鍵をslave側のauthorized_keysファイルへ渡す(アペンドする)ことで、接続されるようになります!

その他

Disable security

https://wiki.jenkins-ci.org/display/JENKINS/Disable+security

[Jenkins] ビルドトリガ(定期的に実行)設定についてのまとめ

http://qiita.com/koara-local/items/79cb9c08e77ac9d94b1d

master and slave

Dockerコンテナを使って自動ビルドを実行する
Jenkins のスレーブを設定する
【ぼっさんのJenkins講座】マスタースレーブを体験しよう – ノード作成編
認証情報の追加 予め作成しておく。あとでNode新規作成時に認証情報として指定する。
 http://<jenkins_host>/jenkins/credentials/store/system/domain/_/newCredentials

種類SSHユーザー名と秘密鍵
スコープグローバル
ユーザー名スレーブ側のユーザー名/home/salve/なら「slave」にする
秘密鍵マスター側jenkinsで ssh-keygen でid_rsaをつくったときの.pubがついてないほうのファイルを指定する。それか直接テキスト指定する。
パスフレーズマスター側jenkinsで ssh-keygen でid_rsaをつくったときのパスワード。パスワード無しで作成しておく。
ID空欄
説明認証情報を区別するための説明です。認証情報はスレーブ側のユーザー名のぶんだけ別に必要

SSHのknown_hostsをスマートに更新する

開発者(個人)のためのJenkins - Slave編

Jenkins Master-Slave setup and configuration with screenshots

example

slave側

master側

jenkins_master@ryu:~$ sudo cat /var/lib/jenkins/.ssh/known_hosts
|1|YyORgEx2VGz7TxxHcLaG9eYiBII=|fJbJHillT/v40/rzjaz1oKYqwrs= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBK80ApPuNcCciu/6M8FrCybAnmZVLZML7O7bI9leGH3CsiQzIJawro84Ql6YTC0BQTDU7du/6SOu/3+bv5gOXVM=
|1|ZPV6QgFXxW8AnKJCo0La7H6nG3c=|v1Cbbk3JeYMvbriv2mHzpIC7l7o= ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3Q4nIWIcCooZJrMMdJEKG8lJ2x2AV4CQyQRipZYsdQ/6uf2FKrJ2chv1lTuh4rf3TJ1m8X0rrwowrznmC1X0pwv12NJ8DRi5gKmGXZW+4jfm6jI64X36FGmKuNHpbQFI4EYRZ2brw3C7n+sEeugLTZsECsnRogaP4rS5H4chgfFZr2Yd6tjW9QByEZa3Ne0Jb/syKrww3jh663TnZqwmBGxBh3XB1JxzXwDkXpOww/vWXw8oMzLNvUayTzM8AxiD/ZZTBMd1CZiZQMb6JqoNHnKwH4NpLO1MLg7E5FoYjqWXkZWrAktoOcyiAnB0qRzc/OueErVI7JDrzSDKhhM57
|1|24/Q3eYsAEB09s+N19nDEXZpJ4M=|CkEUAZ4+npXleidFkMVVLicZxbw= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBK80ApPuNcCciu/6M8FrCybAnmZVLZML7O7bI9leGH3CsiQzIJawro84Ql6YTC0BQTDU7du/6SOu/3+bv5gOXVM=
|1|NhJMkyvw9mOOTu5Zrmzjuds/C4s=|fA8CTs3TLkATcUDPc77BlLkL3pw= ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJkVGNw3SmxSIImXko1un7CRX8MlL7jkfoZDaMWUw2PG
|1|6SsqtrKDZkQ+iKQdOdQQqdsYdcw=|fKZY6xrchYiDh5lQCHPRWi5BH10= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBDw058kch00nuVjT6h8Ip0k0q97vf1mGMyWIZHHb+hjjlsV17Bjs5LIQxxBE+EucGnXHT96TQkRW3Fxfz5fUUtg=
②|1|n9Oa9YTgVosAu2rDZMwuQwFf8G0=|5nn8Mkeggp0RdR/56bb/F1n+imY= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBDw058kch00nuVjT6h8Ip0k0q97vf1mGMyWIZHHb+hjjlsV17Bjs5LIQxxBE+EucGnXHT96TQkRW3Fxfz5fUUtg=
①|1|c57dMJgWXDemGyJENOwFWdTsnzY=|8bG6E8a6zZrIIe2vYeNk4rFgiHo= ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC8OdszqQYHJjuWDmsW3CRO9udWfMF3W21x0Ci5hO4v+Ot0CWr0mi4EcChYTZZfmDGLaxh+g54V+YhIkDt4y4HjQPE3bKqWifV0v26mcGeE+WBYK3+0LAGsGTbY8GDsprSegbo/RpLZhkpXHe+cG9LH4spoJ9R0Ywat31Oum6fgBd4jnJq6GZufwng438J88GebmHcUfUlkQ84z4Whj/MxYQFxnbHgfMeO87dHU1jDYvDYohIVxYw6MCQkgsgJXnmk6WIt5JBD8opVIVovt1DWjeqfcFdNMAObi2iIcpoxOPl+7VNiexe8iR7xPnQXrLk+R4pwc1rlTD10uWbF5Ij9f

example2 JNLPでNode起動

http://kazuhito-m.github.io/tech/2016/12/02/jenkins-webstart-node-invisible

master側

Jenkinsの画面にて、 Jenkinsの管理 -> グローバルセキュリティの設定 画面へ行く

Jenkinsの画面にて、 Jenkinsの管理 -> ノードの管理 -> 新規ノード作成 で、ノードを作成

ノード名ubdt12045.test
リモートFSルート/home/jenkins_slave
ラベルubdt12045.test
起動方法Launch agent via Java Web Start

設定を保存する。

以下が表示される

Connect agent to Jenkins one of these ways:
 -Launch agent from browser
 -Run from agent command line:
  java -jar slave.jar -jnlpUrl http://<jenkins master hostname>:<port>/jenkins/computer/ubdt12045.test/slave-agent.jnlp -secret <文字列>

slave側

javaをインストールしておく

slave.jar をmasterから取得しておく

~$ cd /home/jenkins_slave
~$ wget http://<jenkins master hostname>:<port>/jenkins/jnlpJars/slave.jar

slave.jar を実行

~$ java -jar slave.jar -jnlpUrl http://<jenkins master hostname>:<port>/jenkins/computer/ubdt12045.test/slave-agent.jnlp -secret <文字列> &

トップ   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS