通过堡垒机进入的 Linux 操作系统,无法直接使用 WinSCP 等工具进行文件的上传下载。
可使用 SecureCRT 先进入命令行模式
配置 Linux 堡垒机的连接方式
选择要进入的堡垒机
文件 -> 连接 SFTP 标签页
# 切换本地目录
sftp> lcd "D:\temp"
# 切远程地目录
sftp> cd home
# 查看本地的当前目录
sftp> lpwd
# 查看远程主机当前目录
sftp> pwd
# 先切换到远程目录,
sftp> cd /home
#上传一个本地文件到远程目录
sftp> put "D:\temp\logs\222.png"
#上传一个本地目录到远程目录
sftp> put -r "D:\temp\logs"
#上传多个本地文件到远程目录
sftp> mput "D:\temp\logs\*.png"
#上传一个本地目录到远程目录
sftp> mput -r "D:\temp\log*"
# 先切换到本发要保存的目录,
sftp> lcd D:\temp\logs
#下载一个远程文件到本地目录
sftp> get /home/logs/111.png
#下载一个远程目录到本地目录
sftp> get -r /home/logs
#下载多个远程文件(支持通配符*)到本地目录
sftp> mget /home/*.png
#下载多个远程目录(支持通配符*)到本地目录
sftp> mget -r /home/log*
# Windows 目录最好加上双引好,防止目录中存在空格问题
sftp> cd /home
sftp> pwd
/home
sftp> put "D:\temp\logs\222.png"
Uploading 222.png to /home/222.png
100% 248KB 248KB/s 00:00:00
D:/temp/logs/222.png: 254491 bytes transferred in 0 seconds (248 KB/s)
sftp> put -r "D:\temp\logs"
Uploading 111.png to /home/logs/111.png
100% 239KB 239KB/s 00:00:00
111.png: 245673 bytes transferred in 0 seconds (239 KB/s)
Uploading 222.png to /home/logs/222.png
100% 248KB 248KB/s 00:00:00
222.png: 254491 bytes transferred in 0 seconds (248 KB/s)
Uploading test.txt to /home/logs/test.txt
100% 292KB 292KB/s 00:00:00
test.txt: 300000 bytes transferred in 0 seconds (292 KB/s)
Uploading test.txt to /home/logs/logs/test.txt
100% 292KB 292KB/s 00:00:00
logs/test.txt: 300000 bytes transferred in 0 seconds (292 KB/s)
sftp>
sftp>
sftp>
sftp> lcd D:\temp\logs
sftp> lpwd
D:/temp/logs
sftp> get /home/logs/111.png
Downloading 111.png from /home/logs/111.png
100% 239KB 239KB/s 00:00:00
/home/logs/111.png: 245673 bytes transferred in 0 seconds (239 KB/s)
sftp> get -r /home/logs
Downloading test.txt from /home/logs/test.txt
100% 292KB 292KB/s 00:00:00
test.txt: 300000 bytes transferred in 0 seconds (292 KB/s)
Downloading 111.png from /home/logs/111.png
100% 239KB 239KB/s 00:00:00
111.png: 245673 bytes transferred in 0 seconds (239 KB/s)
Downloading 222.png from /home/logs/222.png
100% 248KB 248KB/s 00:00:00
222.png: 254491 bytes transferred in 0 seconds (248 KB/s)
Downloading test.txt from /home/logs/logs/test.txt
100% 292KB 292KB/s 00:00:00
logs/test.txt: 300000 bytes transferred in 0 seconds (292 KB/s)
sftp>