THE IT IDEAS

  • Home

Tuesday, 7 April 2015

Create SFTP User with chroot in AWS EC2

 THE IT IDEAS     15:12     ec2.chroot, sftp   

Create User with below command

#adduser --shell=/bin/false theitideas

Provide permission of home directory

#chown root:theitideas /home/theitideas/
#chmod 755 /home/theitideas/

Create Folder to be access via sftp and provide permission

#mkdir /home/theitideas/workspace
#chown theitideas:theitideas /home/theitideas/workspace/
#chmod 755 /home/theitideas/workspace/


Generate ssh key to access instance via sftp


#cd /home/theitideas
#mkdir .ssh
#cd .ssh
#ssh-keygen -t rsa -f theitideas
#touch authorized_keys
#cat theitideas.pub > authorized_keys
#cd ..
#ssh-keygen -A

Change the permission of generated key and .ssh folder

#chmod go-w /home/theitideas/
#chown -R theitideas:theitideas .ssh/
#chmod 700 .ssh/
#chmod 600 .ssh/authorized_keys

Open ssh config file and make below mentioned changes.

#nano /etc/ssh/sshd_config


find
"Subsystem sftp /usr/lib/openssh/sftp-server" line in opened file and add "#" on first to comment out the line


#Subsystem sftp /usr/lib/openssh/sftp-server

and add the following at the bottom of the file:

Subsystem sftp internal-sftp
Match User theitideas
    ChrootDirectory %h
    ForceCommand internal-sftp
    X11Forwarding no
    AllowTCPForwarding no


Once close the file restart the ssh service with below command

#service ssh restart

You can download (theitideas) private key from server then you can able to access sftp connection with private key (theitideas).

command to connect sftp with private key

#sftp -i theitideas theitideas@12.34.56.67


Hurray !!! :)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

Like Us !!!

Recent Posts

Blog Archive

  • ►  2016 (1)
    • ►  April (1)
  • ▼  2015 (12)
    • ►  August (1)
    • ►  May (2)
    • ▼  April (8)
      • How to run a simple PHP web server
      • Install apache2 Webserver, php5 and php module wi...
      • Use PHP5-FPM with Apache 2 on Ubuntu 14.04
      • Give permission yo users to run command with SUDO
      • Error : Could not load host key: /etc/ssh/ssh_hos...
      • Create SFTP User with chroot in AWS EC2
      • How to Delete ElasticBeanstalk bucket
      • How to Use Python ‘SimpleHTTPServer’ to Serve File...
    • ►  March (1)
  • ►  2014 (23)
    • ►  December (8)
    • ►  November (12)
    • ►  April (2)
    • ►  March (1)
  • ►  2013 (7)
    • ►  December (1)
    • ►  April (1)
    • ►  March (1)
    • ►  February (1)
    • ►  January (3)
  • ►  2012 (15)
    • ►  December (6)
    • ►  November (9)

Categories

apache2 EC2 error mysql php ubuntu aws aws rds browser github installation linux mount s3 AWS Bucket CentOS Computer DocumentRoot change How to Benchmarking Webserver IP LAMP Restart Computer SCP command SQL SERVER XRDP administrator amazon rds backup basic commands chat command line disable download drupal ec2.chroot environment external storage device fstab functions geoip gmail google home page iis instance internet java mod rewrite mongodb multiple login network password one password php5 php5-fpm php7 private browsing python repair filesystem repo reset password rhel sa password same computer script sftp share skype ssh tomcat ubuntu 16.04 ubuntu16 visudo windows 8 youtube
JobsMagBlogJobsMag.InThingsGuide

Popular Posts

  • Install MongoDB php driver in XAMPP/LAMPP
    To install the php driver for MongoDB Prerequisite :: #sudo apt-get install autoconf #export PHP_AUTOCONF=/usr/bin/autoconf #sudo apt...
  • How to Install PHP 7.0, Apache 2.4.18, & MySQL 5.7 on Ubuntu 16.04 LTS
    Update your repo list with below command $ sudo apt-get update -- > Install Apache 2.4.18 $ sudo apt-get install apac...
  • Share Internet from one PC to another PC
    Open Network Connections by clicking the Start button , clicking Control Panel , clicking Network and Internet , clicking Network and S...

Copyright © THE IT IDEAS | Powered by Blogger