Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Combing the process of adding sftp users to linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Sometimes, for special needs, the server needs to activate sftp to transfer files to the peer server instead of ftp. Write this as follows:

Operating system linux

1. Add new users

Useradd-g sftponly-s "/ bin/false"-d "/ ftp/usftpuser/" usftpuser

2 、 / etc/ssh/sshd_config

Modify

Subsystem sftp internal-sftp

UsePAM yes

New matching users

Match User usftpuser

ChrootDirectory / ftp/usftpuser

X11Forwarding no

AllowTcpForwarding no

ForceCommand internal-sftp

Note: the / ftp/usftpuser/,usftpuser directory here must be a root user with 755 permissions, otherwise it cannot be used.

Service sshd restart

Then you can try to log in:

[root@cpsvpn ~] # sftp usftpuser@193.168.4.30

Connecting to 193.168.4.30...

Usftpuser@193.168.4.30's password:

Sftp >

Sftp >

Sftp > ls

Sftp >

Sftp > pwd

Remote working directory: /

Note: if the user usftpuser needs to use the current directory, there must be an administrative root to establish a directory with permissions, otherwise it cannot be used.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report