- SSH相關(guān)
登錄SSH服務(wù)器
ssh username@ip -p 端口
ssh userName@192.168.1.1 -p 123
直接復(fù)制SSH服務(wù)器上的數(shù)據(jù)到本地
- SCP遠(yuǎn)程文件操作
scp [可選參數(shù)] file_source file_target
從本地復(fù)制文件到遠(yuǎn)程
scp local_file remote_username@remote_ip:remote_folder
或者
scp local_file remote_username@remote_ip:remote_file
或者
scp local_file remote_ip:remote_folder
或者
scp local_file remote_ip:remote_file
復(fù)制目錄命令格式:
scp -r local_folder remote_username@remote_ip:remote_folder
或者
scp -r local_folder remote_ip:remote_folder
本地復(fù)制到遠(yuǎn)程的例子:
//復(fù)制文件
scp /home/space/music/1.mp3 root@www.runoob.com:/home/root/others/music
scp /home/space/music/1.mp3 root@www.runoob.com:/home/root/others/music/001.mp3
//復(fù)制目錄
scp -r /home/space/music/ root@www.runoob.com:/home/root/others/
遠(yuǎn)程復(fù)制文件到本地示例:
//復(fù)制單個(gè)文件
scp root@www.runoob.com:/home/root/others/music /home/space/music/1.mp3
//復(fù)制目錄
scp -r www.runoob.com:/home/root/others/ /home/space/music/
如果遠(yuǎn)程服務(wù)器防火墻有為scp命令設(shè)置了指定的端口侍郭,我們需要使用 -P 參數(shù)來設(shè)置命令的端口號(hào)饭庞,命令格式如下
scp -P 4588 remote@www.runoob.com:/usr/local/sin.sh /home/administrator