通过windows cmd 连接linux远程服务器传输文件

通过windows cmd ssh连接linux远程服务器|scp 传输文件

1.windows cmd连接远程服务器

1.1默认端口22连接

ssh <登录账号>@<服务器ip> // 例如 ssh root@127.0.0.1

输入账号的密码即可进入ssh

1.2指定端口连接方式

ssh -P <服务端口> <登录账号>@<服务器ip> // 例如 ssh -P 2222 root@127.0.0.1

输入账号的密码即可进入ssh

2.通过scp传输文件

//上传本地文件a.txt 到服务器的path路径下

scp /D:/a.txt user@ip:/path/

//上传本地D盘文件夹a到服务器的文件夹中

scp -r /D:/a user@ip:/path/

//下载服务器path路径下的文件a.txt 到本地D盘

scp user@ip:/path/a.txt /D:/path

//下载服务器path路径下的文件夹a到本地D盘

scp -r user@ip:/path/a /D:/path

常规选项

-P:指定 SSH 端口(大写 P)

scp -P 55555 username@remote_host:/path/to/remote/file /path/to/local/directory

-r:递归复制整个目录

scp -r username@remote_host:/path/to/remote/directory /path/to/local/directory

-p:保持文件的修改时间、访问时间和模式(权限)

scp -p username@remote_host:/path/to/remote/file /path/to/local/directory

#学习笔记#

原文链接:,转发请注明来源!