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:服務器要開啟讀寫權限