国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Linux安裝sftp服務(wù)

這篇具有很好參考價(jià)值的文章主要介紹了Linux安裝sftp服務(wù)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

處理步驟:

1.關(guān)閉防火墻和selinux

[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
 ? Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
 ? Active: inactive (dead)
 ? ? Docs: man:firewalld(1)
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# vi /etc/sysconfig/selinux
# 把文件中的SELINUX=enforcing 改為SELINUX=disabled
[root@localhost ~]# setenforce 0
setenforce: SELinux is disabled

2.查看ssh是否已安裝并啟動(dòng)

[root@localhost ~]# ssh -V
OpenSSH_8.2p1, OpenSSL 1.1.1f  31 Mar 2020
[root@localhost ~]# systemctl status sshd
● sshd.service - OpenSSH server daemon
 ? Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
 ? Active: active (running) since Thu 2022-12-01 11:50:01 CST; 4h 26min ago
 ? ? Docs: man:sshd(8)
 ? ? ? ? ? man:sshd_config(5)
 Main PID: 1393 (sshd)
 ?  Tasks: 1
 ? Memory: 1.8M
 ? CGroup: /system.slice/sshd.service
 ? ? ? ? ? └─1393 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups

3.新建用戶組、用戶和sftp目錄

1.新建目錄

[root@localhost ~]# mkdir -p /data/sftp/sftpuser
[root@localhost ~]# chown root:root /data/sftp/sftpuser
[root@localhost ~]# chmod 755 /data/sftp/sftpuser

2.新建用戶組

[root@localhost ~]# groupadd sftp

3.新建用戶

[root@localhost ~]# useradd -g sftp -d /data/sftp/sftpuser -M -s /sbin/nologin sftpuser
-g指定用戶組、-d指定家目錄、-s nologin 不能登錄系統(tǒng)、-M不創(chuàng)建家目錄
[root@localhost ~]# echo 'xxxxx'|passwd --stdin sftpuser

4.新建sftp可寫目錄

[root@localhost ~]# mkdir -p /data/sftp/sftpuser/upload
[root@localhost ~]# chown -R sftpuser:sftp /data/sftp/sftpuser/upload
[root@localhost ~]# chmod -R 777 /data/sftp/sftpuser/upload

4.配置SSH和SFTP 服務(wù)器

1.備份sshd_config配置文件并查看文件中的有效配置

[root@localhost ~]# cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
[root@localhost ~]# egrep -v '^$|^#' /etc/ssh/sshd_config
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
SyslogFacility AUTHPRIV
PermitRootLogin yes
AuthorizedKeysFile  .ssh/authorized_keys
PasswordAuthentication yes
ChallengeResponseAuthentication no
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
UsePAM yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
Subsystem   sftp    /usr/libexec/openssh/sftp-server

2.修改sshd_config配置文件

注釋掉:
Subsystem   sftp    /usr/libexec/openssh/sftp-server
新增:
Subsystem sftp internal-sftp
Match Group sftp
ChrootDirectory /data/sftp/%u
ForceCommand internal-sftp
# 下面兩項(xiàng)是與安全有關(guān)
AllowTcpForwarding no
X11Forwarding no #設(shè)置不允許SSH的X轉(zhuǎn)發(fā)
?
[root@localhost upload]# egrep -v '^$|^#' /etc/ssh/sshd_config
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
SyslogFacility AUTHPRIV
PermitRootLogin yes
AuthorizedKeysFile  .ssh/authorized_keys
RSAAuthentication yes
PubkeyAuthentication yes
PasswordAuthentication yes
ChallengeResponseAuthentication no
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
UsePAM yes
X11Forwarding no
PrintMotd no
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
Subsystem sftp internal-sftp
Match Group sftp
ChrootDirectory /data/sftp/%u
ForceCommand internal-sftp
AllowTcpForwarding no

5.重啟ssh服務(wù)

[root@localhost ~]# systemctl restart sshd

6.新建測試文件并授權(quán)

[root@localhost upload]# echo 111 > 1.txt
[root@localhost upload]# ll
總用量 4.0K
-rw------- 1 root root 4 12月  1 17:43 1.txt
新建的文件權(quán)限默認(rèn)為600,需要手動(dòng)授權(quán)777
[root@localhost upload]# chmod 777 1.txt 
[root@localhost upload]# ll
總用量 4.0K
-rwxrwxrwx 1 root root 4 12月  1 17:43 1.txt

7.從另一臺(tái)機(jī)器測試sftp可用性

[root@centos-01 data]# sftp sftpuser@192.168.137.16
sftpuser@192.168.137.16's password: 
Connected to 192.168.137.16.
sftp> ls -l
drwxrwxrwx ?  2 1002 ? ? 1002 ? ? ? ? 4096 Dec  1 09:38 upload
sftp> cd upload/
sftp> ls -l
-rwxrwxrwx ?  1 root ? ? root ? ? ? ? ?  4 Dec  1 09:36 1.txt
sftp> get 1.txt 
Fetching /upload/1.txt to 1.txt
/upload/1.txt ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 100% ?  4 ? ? 7.4KB/s ? 00:00 ? ?
sftp> exit
[root@centos-01 ~]# ll
-rwxr-xr-x 1 root root ? ? 4 Dec  1 17:44 1.txt

OK!文章來源地址http://www.zghlxwxcb.cn/news/detail-443593.html

到了這里,關(guān)于Linux安裝sftp服務(wù)的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Linux如何開啟和關(guān)閉防火墻

    防火墻是一種安全機(jī)制,可以保護(hù)計(jì)算機(jī)網(wǎng)絡(luò)不受未經(jīng)授權(quán)的訪問和攻擊。防火墻位于計(jì)算機(jī)網(wǎng)絡(luò)的邊緣,監(jiān)控網(wǎng)絡(luò)傳輸?shù)牧髁?,根?jù)預(yù)設(shè)的規(guī)則過濾進(jìn)出網(wǎng)絡(luò)的數(shù)據(jù)包,阻止不安全的數(shù)據(jù)包進(jìn)入網(wǎng)絡(luò),從而保護(hù)網(wǎng)絡(luò)不受攻擊。 在Linux系統(tǒng)中,防火墻是一個(gè)重要的安全措施。

    2024年02月06日
    瀏覽(24)
  • Linux打開和關(guān)閉防火墻指令

    設(shè)置開機(jī)啟用防火墻:systemctl enable firewalld.service 啟動(dòng)防火墻:systemctl start firewalld 設(shè)置開機(jī)禁用防火墻:systemctl disable firewalld.service 關(guān)閉防火墻(有時(shí)間限制):systemctl stop firewalld 檢查防火墻狀態(tài):systemctl status firewalld

    2024年02月16日
    瀏覽(15)
  • Ubuntu----Linux命令-----防火墻(查看、關(guān)閉、啟動(dòng))

    Ubuntu----Linux命令-----防火墻(查看、關(guān)閉、啟動(dòng))

    一、查看防火墻狀態(tài) 命令:ufw status 說明: ??????? ·活動(dòng):防火墻是開啟的 ??????? ·不活動(dòng):防火墻是關(guān)閉的 二、開啟防火墻 命令:sudo ufw enable 開啟防火墻后,可以查看防火墻狀態(tài) 三、關(guān)閉防火墻 命令:sudo ufw disable

    2024年02月09日
    瀏覽(28)
  • 藍(lán)易云:linux怎么關(guān)閉防火墻詳細(xì)教程

    在Linux下關(guān)閉防火墻可以通過以下步驟實(shí)現(xiàn): 1. 檢查防火墻狀態(tài) 首先需要檢查當(dāng)前系統(tǒng)的防火墻狀態(tài),可以使用以下命令: ``` sudo systemctl status firewalld ``` 如果防火墻當(dāng)前正在運(yùn)行,會(huì)顯示出如下信息: ``` ● firewalld.service - firewalld - dynamic firewall daemon ? ?Loaded: loaded (/usr/li

    2024年02月14日
    瀏覽(23)
  • Linux-cenos6-防火墻關(guān)閉

    Linux-cenos6-防火墻關(guān)閉

    service iptables stop 1、基本操作 # 查看防火墻狀態(tài) 1 service iptables status # 停止防火墻 1 service iptables stop # 啟動(dòng)防火墻 1 service iptables start # 重啟防火墻 1 service iptables restart # 永久關(guān)閉防火墻 1 chkconfig iptables off # 永久關(guān)閉后重啟 1 chkconfig iptables on 2、開啟80端口 1 vim /etc/sysconfig/ipta

    2024年02月06日
    瀏覽(17)
  • linux查看防火墻,開放端口、關(guān)閉端口-運(yùn)維必備

    查看防火墻狀態(tài):active (running) 即是開啟狀態(tài) 如果不是顯示active狀態(tài),需要打開防火墻 查看所有已開放的端口 新增防火墻開放端口 關(guān)閉防火墻端口 配置結(jié)束后需要輸入重載命令并重啟防火墻以生效配置 firewalld的基本使用命令 配置firewalld-cmd命令 systemctl相關(guān)命令 查看端口號(hào)

    2024年02月13日
    瀏覽(16)
  • linux(centos7)常用命令 開啟關(guān)閉防火墻

    linux(centos7)常用命令 開啟關(guān)閉防火墻

    在 CentOS 7 中,默認(rèn)的防火墻服務(wù)是 firewalld ,它取代了之前版本中的 iptables 。 firewalld 使用了名為“firewall-cmd”的命令行工具來管理防火墻規(guī)則。 firewalld 的關(guān)鍵概念包括: 區(qū)域 (Zones) : 用于定義不同信任級(jí)別的網(wǎng)絡(luò)連接。你可以為不同的網(wǎng)絡(luò)接口或來源 IP 分配不同的區(qū)域,

    2024年01月21日
    瀏覽(83)
  • Centos上 關(guān)閉Linux防火墻(iptables) 及 SELinux

    一、關(guān)閉防火墻 1、重啟后永久性生效: 開啟: chkconfig iptables on 關(guān)閉: chkconfig iptables off 2、即時(shí)生效,重啟后失效: 開啟: service iptables start 關(guān)閉: service iptables stop 在開啟了防火墻時(shí),做如下設(shè)置,開啟相關(guān)端口,修改?/etc/sysconfig/iptables?文件,添加以下內(nèi)容: -A INPUT

    2024年02月08日
    瀏覽(19)
  • Linux Centos7 防火墻(開啟、關(guān)閉、重啟、狀態(tài)、端口)

    Linux Centos7 防火墻(開啟、關(guān)閉、重啟、狀態(tài)、端口)

    防火墻(Firewall)技術(shù)是通過有機(jī)結(jié)合各類用于安全管理與篩選的軟件和硬件設(shè)備,幫助計(jì)算機(jī)網(wǎng)絡(luò)于其內(nèi)、外網(wǎng)之間構(gòu)建一道相對(duì)隔絕的保護(hù)屏障,以保護(hù)用戶資料與信息安全性的一種技術(shù)。 防火墻功能 防火墻對(duì)流經(jīng)它的網(wǎng)絡(luò)通信進(jìn)行掃描,這樣能夠過濾掉一些攻擊,以免

    2024年02月02日
    瀏覽(55)
  • 阿里云服務(wù)器開啟所有端口,防火墻關(guān)閉情況下無法訪問rabbitmq 15672端口

    阿里云服務(wù)器開啟所有端口,防火墻關(guān)閉情況下無法訪問rabbitmq 15672端口

    記錄一下自己遇到的問題, 在開啟所有端口且關(guān)閉防火墻 的情況下,無法訪問 ?,排查問題后發(fā)現(xiàn)是因?yàn)槲抑苯觗ocker pull rabbitmq,未安裝RabbitMQ的web管理界面。 解決方法如下: 1、進(jìn)入rabbitmq容器 ?2、執(zhí)行 3、刷新頁面即可訪問 ?

    2024年02月16日
    瀏覽(23)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包