LoginSignup
5
6

More than 5 years have passed since last update.

AWSで簡易なSFTPサーバー構築 - SFTPサーバー設定

Posted at

ec2-userでSSHログイン

rootユーザに変更

$ sudo su -

ユーザー作成

# useradd ユーザー名

rootユーザーからexit

# exit

作成したユーザーに変更

$ sudo su 作成したユーザー名

作成したユーザーのホームディレクトリに移動

$ cd /home/作成したユーザー名

.sshディレクトリ作成

$ mkdir .ssh

.sshディレクトリのパーミッション(権限)を700に変更

$ chmod 700 .ssh

.sshの直下にauthorized_keysファイル作成

$ touch .ssh/authorized_keys

authorized_keysファイルのパーミッションを600に変更

$ chmod 600 .ssh/authorized_keys

秘密鍵公開鍵の準備

Puttygenで公開鍵のスクリーンをドラッグしてコピー

authorized_keysに公開鍵を貼り付け

cat >> .ssh/authorized_keys

入力モードになるので、(Puttyの場合)Shift + insertボタン押下
Enter
:q + Enter
でプロンプトに戻る

別のPuttyセッションを立上、作成したユーザー名で作成した秘密鍵でログインできることを確認

sftpコマンドでのみ接続を許可させる

authorized_keysの先頭に下記の記載を追加し、改行を入れる。
/home/[user_dir]/.ssh/authorized_keys
command="internal-sftp"

あとはこちらの記事を参考にできました。ありがとうございます。

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6