オレオレ証明書で sftp scp ssh

19 3月

オレオレ証明書で外部から ssh や scp や sftp したいTIP

sftp、ftp用にユーザを作成

sftpのための設定
# useradd justsftpuser01
# useradd justftpuser01
(justftpuser01のみパスワード設定)
# passwd justftpuser01

sftp用に証明書の作成

# su – justsftpuser01
$ sh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/justsftpuser01/.ssh/id_rsa):
Created directory ‘/home/justsftpuser01/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/justsftpuser01/.ssh/id_rsa.
Your public key has been saved in /home/justsftpuser01/.ssh/id_rsa.pub.
The key fingerprint is:
07:33:ed:2e:d8:af:a6:65:bb:e3:f1:50:df:33:4c:93 justsftpuser01@ip-10-243-11-32
The key’s randomart image is:
+–[ RSA 2048]—-+
| |
| . |
| + . |
| = . |
| S + E |
| o + . + . |
| . B . . = |
| ooB o |
| .+=+o |
+—————–+
$ cd .ssh
$ cp id_rsa.pub authorized_keys
$ chmod 600 authorized_keys
id_rsaキーは、pemキーとして接続するユーザへ配布してください。

sftp 接続方法は
linux の場合 sftp接続の際にキーを指定します。
windows の場合 puttygen等で キーを ppk 形式に変更してから使用してください。

$ sftp -oIdentityFile=sftp.pem justsftpuser01@10.243.11.32
ftpのための設定
vsftpdのインストールと設定ファイルの変更します。
また、今回は xinetd経由で起動させます。(IP制限の指定もできるため)

# yum –disablerepo=* –enablerepo=idc* -c http://54.249.19.129//centos/6.5/idc/repo/mwex-54.repo install vsftpd xinetd
# vi /etc/vsftpd/vsftpd.conf
anonymous_enable=NO へ変更
listen=YESをコメントにして無効
tcp_wrappers=YESをコメントにして無効

# vi /etc/xinet.d/vsftpd
service ftp
{
flags = NOLIBWRAP
socket_type = stream
wait = no
user = root
server = /usr/sbin/vsftpd
server_args = /etc/vsftpd/vsftpd.conf
log_on_failure += USERID
disable = no
#only_from = 許可するIPアドレス
}

# /etc/init.d/xinetd reload

コメントを残す