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 !!! :)
#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 !!! :)