linux登录远程服务器及scp命令传输文件(ssh(Connection refused lost connection) 错误),及centos7.3防火墙操作

登录远程服务器需要指定ssh开放的端口号,一般在购买远程服务器上会有显示:ssh -p端口号 登录账号名称(一般是root)@远程服务器ip,然后它会提示你输入密码

scp命令传输文件时要指定开放的端口号,否则它默认的22端口是拒绝连接的。(错误示范)
scp -r /home/lin/Desktop/adslproxy/ root@xx.xx.xx.xx:/home/download

lin@ubuntu:~/Desktop/git$ scp -r /home/lin/Desktop/adslproxy/ root@xx.xx.xx.xx:/home/download
ssh: connect to host xx.xx.xx.xx port 22: Connection refused
lost connection

scp指定端口号传输文件

scp -r -P端口号 /home/lin/Desktop/adslproxy/ root@xx.xx.xx.xx:/home/download
root@xx.xx.xx.xx's password: 
config.py                                     100%  578     0.6KB/s   00:00    
__init__.py                                   100%  147     0.1KB/s   00:00    
db.cpython-36.pyc                             100% 2622     2.6KB/s   00:00    
config.cpython-36.pyc                         100%  475     0.5KB/s   00:00    
__init__.cpython-36.pyc                       100%  346     0.3KB/s   00:00    
api.cpython-36.pyc                            100% 1505     1.5KB/s   00:00    
sender.cpython-36.pyc                         100% 3019     3.0KB/s   00:00    
sender.py                                     100% 3039     3.0KB/s   00:00    
api.py                                        100% 1508     1.5KB/s   00:00    
db.py                                         100% 1926     1.9KB/s   00:00    

由于预装系统是centos7.3,防火墙操作命令与linux还是有些区别
1、查看防火墙服务状态 systemctl status firewalld

[root@localhost download]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)

2、查看防火墙运行状态(是否开启关闭)firewall-cmd –state

[root@localhost download]# firewall-cmd --state
running

3、关闭防火墙 service firewalld stop

[root@localhost download]# service firewalld stop
Redirecting to /bin/systemctl stop firewalld.service

4、开启防火墙service firewalld start

[root@localhost download]# service firewalld start
Redirecting to /bin/systemctl start firewalld.service

5、重启防火墙 service firewalld restart

[root@localhost download]# service firewalld restart
Redirecting to /bin/systemctl restart firewalld.service

6、查看开放端口 firewall-cmd –list-all

trusted (active)
  target: ACCEPT
  icmp-block-inversion: no
  interfaces: eth0
  sources: 
  services: 
  ports: 8888/tcp   #这里开放了8888端口
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 

7、开放指定端口[root@localhost download]# firewall-cmd –permanent –add-port=22/tcp 这里的22是要开放的端口

[root@localhost download]# firewall-cmd --permanent --add-port=22/tcp
success

8、关闭指定端口 firewall-cmd –permanent –remove-port=22/tcp

[root@localhost download]# firewall-cmd --permanent --remove-port=22/tcp
success

9、重启防火墙(开启或关闭防火墙后需要重启才能生效)firewall-cmd –reload

[root@localhost download]# firewall-cmd --reload
success
  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值