日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

scp构造端口_指定端口号的scp

發布時間:2023/12/9 编程问答 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 scp构造端口_指定端口号的scp 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

指定端口號的scp

我正在嘗試將文件從遠程服務器scp到我的本地計算機。 只有80端口可以訪問。

我試過了:

scp -p 80 username@www.myserver.com:/root/file.txt .

但得到了這個錯誤:cp: 80: No such file or directory

如何在scp命令中指定端口號?

One Two Three asked 2018-12-28T21:01:11Z

9個解決方案

1105 votes

與ssh不同,scp使用大寫P開關來設置端口而不是小寫p:

scp -P 80 ... # Use port 80 to bypass the firewall, instead of the scp default

小寫p開關與scp一起用于保存時間和模式。

以下是scp手冊頁的摘錄,其中包含有關兩個開關的所有詳細信息,以及為scp選擇大寫P的原因解釋:

-P port指定要在遠程主機上連接的端口。 請注意,此選項使用大寫“P”編寫,因為-p已經存在?? 保留用于保留rcp(1)中文件的時間和模式。

-p保留原始文件的修改時間,訪問時間和模式。

Michael Goldshteyn answered 2018-12-28T21:01:46Z

45 votes

一個額外的提示。 在scp命令之后放置'-P'選項,無論你正在進入的機器是否是第二個(也就是目的地)。 例:

scp -P 2222 /absolute_path/source-folder/some-file user@example.com:/absolute_path/destination-folder

Gooshan answered 2018-12-28T21:02:09Z

37 votes

你知道什么比man ssh_config更酷嗎? 沒有

如果您多次使用此服務器,請使用以下條目設置/創建man ssh_config文件:

Host www.myserver.com

Port 80

要么

Host myserver myserver80 short any.name.u.want yes_anything well-within-reason

HostName www.myserver.com

Port 80

User username

然后你可以使用:

man ssh_config

要么

man ssh_config

您可以在“主機”行使用ssh,scp,rsync,git和amp; 更多

您可以在配置文件中使用許多配置選項,請參閱:

man ssh_config

Mike answered 2018-12-28T21:03:14Z

24 votes

我正在使用不同的端口然后標準并在文件之間復制文件,如下所示:

scp -P 1234 user@[ip address or host name]:/var/www/mywebsite/dumps/* /var/www/myNewPathOnCurrentLocalMachine

這僅適用于偶爾使用,如果它根據計劃重復,您應該使用rsync和cron job來執行此操作。

Marian Zburlea answered 2018-12-28T21:03:51Z

4 votes

scp help告訴我們端口由大寫字母P指定。

~$ scp

usage: scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]

[-l limit] [-o ssh_option] [-P port] [-S program]

[[user@]host1:]file1 ... [[user@]host2:]file2

希望這可以幫助。

D D answered 2018-12-28T21:04:20Z

2 votes

復制文件到主機:scp?SourceFile?remoteuser@remotehost:/directory/TargetFile

從主機復制文件:scp?-P?2222?user@host:/directory/SourceFile?TargetFile

從主機復制目錄遞歸:scp?-P?2222?user@host:/directory/SourceFile?TargetFile

注意:如果主機使用端口22以外的端口,你可以用-P選項指定它:scp?-P?2222?user@host:/directory/SourceFile?TargetFile

AJ. answered 2018-12-28T21:05:04Z

1 votes

這可以通過-P開關指定端口來實現:

scp -i ~/keys/yourkey -P2222 file ubuntu@host:/directory/

Vaseem007 answered 2018-12-28T21:05:35Z

0 votes

如果需要將本地文件復制到服務器(指定端口)

scp -P 3838 /the/source/file username@server.com:/destination/file

Turan Zamanl? answered 2018-12-28T21:05:58Z

0 votes

使用scp命令的另一個端口使用大寫P這樣

scp -P port-number source-file/directory user@domain:/destination

你好阿里

Hasan Barary answered 2018-12-28T21:06:27Z

總結

以上是生活随笔為你收集整理的scp构造端口_指定端口号的scp的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。