Onga inc

subtitle

sshの鍵認証を設定する。

wpid-centos_logo2

サーバー設定させ最初に必要となるsshとユーザーの作成に関して解説します。

鍵の作成

パスフレーズはデフォルトのままでいいでしょう。

`
ssh-keygen -t rsa -v
`

ファイル一覧の確認

`
ls -la .ssh
`

id_rsa=>秘密鍵
id_rsa.pub=>公開鍵

パーミションの変更

`
chmod 600 .ssh/id_rsa.pub
`

サーバーへファイルの転送

scpコマンドを使用してファイルを転送します。

`
scp ~/.ssh/id_rsa.pub ユーザ名@IP.ADD.RE.SS:~/.ssh/authorized_keys
`

sshでログイン

`
ssh -i ~/.ssh/id_rsa ユーザ名@IP.ADD.RE.SS
//フォルダ名の省略も可能です。
ssh ユーザ名@IP.ADD.RE.SS
`

ポート番号の変更

コンフィグファイルのバックアップ

`
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.org

vim /etc/ssh/sshd_config
Port= 22 //ポートの設定
PasswordAuthentication no  //パスワード認証の禁止
PermitRootLogin no  //ルートログインの禁止
`

sshの再起動

`
service sshd restart
`

作業用ユーザーの作成

`
useradd testuser
passwd testuser
usermod -G wheel testuser
`

作業用ユーザーのsudo 設定

`

//testuserをwheelグループに追加
usermod -G wheel testuser

//sudoコマンドの権限の編集
visudo

//wheelグループ権限の変更
## Allows people in group wheel to run all commands
%wheel        ALL=(ALL)       ALL

`

作業用ユーザーでのssh接続

`
ssh dotinstall@IP.ADD.RE.SS
`

Onga

A designer, developer and entrepreneur. Spends his time travelling the world with a bag of kites. Likes journalism and publishing platforms.

Comments