標籤:io os 使用 檔案 資料 sp 問題 on c
Windows下我習慣用PUTTY來ssh登入,Mac直接使用Terminal即可。
ssh的一些常用命令:
使用root帳號登入指定ip的伺服器。下面需要把ip換成你自己伺服器的ip。
ssh [email protected]
如果伺服器使用的不是標準連接埠,比如是4567連接埠,則是:
ssh [email protected] -p 4567
MAC下還有視窗方式:
先開啟一個終端,在功能表列點選 Shell - 建立遠端連線。
這時候會出新一個視窗。
選擇安全Shell(ssh),輸入伺服器ip地址和使用者名稱
完成後在SSH菜單上點選 匯出設定,在你的案頭就會看到一個你剛剛命名的 test.terminal。
使用SCP
下面是一個簡單例子:
首先建立一個本地檔案
echo hello, world > a-file.txt
copy本地檔案到伺服器的命令如下:
scp <local file> <remote user>@<remote machine>:<remote path>
如果想Copy遠程檔案到本地,則是:
scp <remote user>@<remote machine>:<remote path> <local file>
如果想複製目錄也是可以的:
scp -r local_folder [email protected]_ip:remote_folder
比如下面命令:scp -r /home/space/music/ [email protected]:/home/root/others/
參數說明:
[[email protected] test]# scp --help
usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
[-l limit] [-o ssh_option] [-P port] [-S program]
[[[email protected]]host1:]file1 [...] [[[email protected]]host2:]file2
-1 強制scp命令使用協議ssh1
-2 強制scp命令使用協議ssh2
-4 強制scp命令只使用IPv4定址
-6 強制scp命令只使用IPv6定址
-B 使用批處理模式(傳輸過程中不詢問傳輸口令或短語)
-C 允許壓縮。(將-C標誌傳遞給ssh,從而開啟壓縮功能)
-p 保留原檔案的修改時間,訪問時間和存取權限。
-q 不顯示傳輸進度條。
-r 遞迴複製整個目錄。
-v 詳細方式顯示輸出。scp和ssh(1)會顯示出整個過程的調試資訊。這些資訊用於調試串連,驗證和配置問題。
-c cipher 以cipher將資料轉送進行加密,這個選項將直接傳遞給ssh。
-F ssh_config 指定一個替代的ssh設定檔,此參數直接傳遞給ssh。
-i identity_file 從指定檔案中讀取傳輸時使用的密鑰檔案,此參數直接傳遞給ssh。
-l limit 限定使用者所能使用的頻寬,以Kbit/s為單位。
-o ssh_option 如果習慣於使用ssh_config(5)中的參數傳遞方式,
-P port 注意是大寫的P, port是指定資料轉送用到的連接埠號碼
-S program 指定加密傳輸時所使用的程式。此程式必須能夠理解ssh(1)的選項。
Mac下使用ssh、scp