ssh推送.py程序到CentOS7服务器端运行出现lost connection错误
(base) F:\workspace>dir
驱动器 F 中的卷是 新加卷
卷的序列号是 C2B9-6277
F:\workspace 的目录
2019/03/13 16:44 <DIR> .
2019/03/13 16:44 <DIR> ..
2019/03/13 16:47 <DIR> .idea
2019/03/13 10:11 <DIR> .ipynb_checkpoints
2019/03/10 23:04 2,554 deepLearning.py
2018/11/22 19:42 3,097 DTW.py
2019/03/09 18:12 43 fun_a.py
2019/03/09 18:15 59 fun_b.py
2019/03/10 16:41 <DIR> GitHub_web_download
2019/03/09 17:16 129 machine_learing.py
2019/03/10 16:46 <DIR> mnist
2019/03/10 11:45 6,272 ResNet.py
2018/11/14 19:21 200 run_readcsv.py
2019/03/12 16:26 4,353 study_day1.ipynb
2019/03/13 10:13 560 Untitled.ipynb
2019/03/13 12:45 675 Untitled1.ipynb
2015/04/16 05:07 83,672,117 vanet-trace-creteil-20130924-1700-1900.csv
11 个文件 83,690,059 字节
6 个目录 189,100,208,128 可用字节
(base) F:\workspace>python machine_learing.py
Finish job, result = 9999
This is Windows
# 使用ssh让192.168.1.191节点服务器代替计算
(base) F:\workspace>ssh jiangshan@192.168.1.191 python < machine_learing.py
The authenticity of host '192.168.1.191 (192.168.1.191)' can't be established.
RSA key fingerprint is 9c:2a:60:69:42:ed:dc:70:26:d0:60:1f:b3:ac:40:3b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.191' (RSA) to the list of known hosts.
jiangshan@192.168.1.191's password:
Finish job, result = 9999
This is Linux
# 把文件copy到192.168.1.191节点服务器上
(base) F:\workspace>scp {fun_a,fun_b}.py jiangshan@192.168.1.191:~/workspace/
Exception: STATUS_ACCESS_VIOLATION at eip=610723FF
eax=00000000 ebx=00010002 ecx=00000000 edx=00000003 esi=00DF0000 edi=001D0010
ebp=0063E6A8 esp=0063E650 program=C:\Program Files (x86)\OpenSSH\bin\ssh.exe, pid 10396, thread main
cs=0023 ds=002B es=002B fs=0053 gs=002B ss=002B
Stack trace:
Frame Function Args
0063E6A8 610723FF (00DF0000, 001D0010, 00010002, 616D1438)
0063E818 6104EE7E (616D1688, 00010002, 00000001, 00000000)
0063E878 6109AD3E (004286FB, 00010002, 00000011, 100EF0D0)
0063E898 6108DF2F (004286FB, 00000002, 00000011, 00000001)
0063ECC8 0042881B (0063ECF0, 00000000, 004104F5, 616D27EA)
0063ED98 0041058A (0063EE00, 0000004F, 00000000, 0063EE14)
0063EDB8 0040FD53 (0063EE00, 100EF6E8, 0063EE00, 0041B469)
0063EDE8 0041AA08 (00000000, 0063EE14, 0063EE00, 0040F7A4)
0063EE48 0040FBD8 (100E8F20, 616D27EA, 100E8C50, 004391B0)
0063F020 004023A0 (00000001, 616D2708, 100E00A8, 0063F078)
0063F060 61005F54 (0063F078, 00000002, 0063F0DC, 0063F088)
0063FF40 6100616B (00000000, 00000000, 00000000, 00000000)
End of stack trace
lost connection
===出错===
# ping一下远端主机
(base) F:\workspace>ping 192.168.1.191
正在 Ping 192.168.1.191 具有 32 字节的数据:
来自 192.168.1.191 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.1.191 的回复: 字节=32 时间=1ms TTL=64
来自 192.168.1.191 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.1.191 的回复: 字节=32 时间<1ms TTL=64
192.168.1.191 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 0ms,最长 = 1ms,平均 = 0ms
能ping通, 则说明是远端192.168.1.191主机的问题
(base) F:\workspace>
# 问题排查
# 1. 检查远程主机是否安装openssh-server服务
打开Xshell
(base) [jiangshan@localhost ~]$ ps -ef | grep sshd
root 7018 1 0 Mar12 ? 00:00:00 /usr/sbin/sshd -D
root 8296 7018 0 04:54 ? 00:00:00 sshd: jiangshan [priv]
jiangsh+ 8300 8296 0 04:54 ? 00:00:00 sshd: jiangshan@pts/0
jiangsh+ 8428 8301 0 05:22 pts/0 00:00:00 grep --color=auto sshd
发现已经安装了
查看防火墙服务状态
(base) [jiangshan@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)
# 查看防火墙运行状态(是否开启关闭)
(base) [jiangshan@localhost ~]$ firewall-cmd --state
not running
# 2. CentOS7临时关闭防火墙
(base) [jiangshan@localhost ~]$ systemctl stop firewalld
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===
# 3. CentOS7禁止开机启动防火墙
(base) [jiangshan@localhost ~]$ systemctl disable firewalld
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files ===
Authentication is required to manage system service or unit files.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===
# CentOS7查看开放端口
(base) [jiangshan@localhost ~]$ firewall-cmd --list-ports
FirewallD is not running
###################### CentOS7开启80端口-tcp协议
### firewall-cmd --zone=public --add-port=80/tcp --permanent###
# 4. 目标服务器要开启权限: 每个人都有读写执行的权限
(base) [jiangshan@localhost ~]$ chmod 777 /home/jiangshan/workspace
(base) [jiangshan@localhost ~]$ ls
anaconda3 Anaconda3-2018.12-Linux-x86_64.sh workspace
(base) [jiangshan@localhost ~]$ whereis scp
scp: /usr/bin/scp /usr/share/man/man1/scp.1.gz
===在CentOS下用scp命令来通过ssh传输文件====
1、从服务器上下载文件
scp jiangshan@192.168.1.191:/path/filename /var/local_dir(本地目标目录)
例如: scp jiangshan@192.168.1.191:/~/hello.txt 把192.168.1.191上的/home/jiangshan/hello.txt 的文件下载到/var/local_dir(本地目标目录)
2、上传本地文件到服务器
scp /path/filename jiangshan@192.168.1.191:/path
例如: scp /var/test.txt jiangshan@192.168.1.191:/var/ 把本机/var/目录下的test.txt文件上传至192.168.1.191这台服务器上的/var/目录中
3、从服务器下载整个目录
scp -r jiangshan@192.168.1.191:/var/remote_dir(远程目录) /var/local_dir(本地目录)
例如:scp -r jiangshan@192.168.0.101:/var/test /var/
4、上传目录到服务器
scp -r local_dir jiangshan@192.168.1.191:remote_dir
例如:scp -r test jiangshan@192.168.1.191:/var/ 把当前目录下的test目录上传到服务器的/var/目录
PS:服务器要开启读写权限
来源:https://www.cnblogs.com/jeshy/p/10525073.html