請問scp的使用... - Linux

Edith avatar
By Edith
at 2009-06-05T13:52

Table of Contents

※ 引述《residentevil (.....)》之銘言:
: 我想要使用scp來傳輸資料給遠端的多台PC
: 不過需要將傳輸動作寫在程式裡
: 也就是說是以system()來執行
: 不能像console一樣手動打入密碼
: 第一次連線的時候會出現
: The authenticity of host '172.16.0.1 (172.16.0.1)' can't be established.
: RSA key fingerprint is a7:45:22:42:a5:c9:e5:31:f1:67:55:a4:a1:a5
: Are you sure you want to continue connecting (yes/no)?
: 這時候需要打入"yes"也不知道該如何處理
: 請問大家知道有什麼方法可以避開這些步驟
: 或是有其他方法能夠讓scp可以用一行指令就完成?
: 感謝!
1.
$ssh-keygen -t rsa 建立一對代表自己身分的 public/private key

第一個問題會問 要把這些KEYS放在哪裡 Enter就好 通常會放在 ~/.ssh 下
第二第三個問題 都按 Enter

後會在 ~/.ssh 下產生兩個檔案 id_ras.pub 與 ida_rsa 前者是公鑰 後者是私鑰

然後
2.
$scp ~/.ssh/id_rsa.pub remoteuser@remotehost:~/.ssh/authorized_keys2
remoteuser's password: 輸入遠端password
id_rsa.pub 100% 235 816.6KB/s 00:00 (表示完成)

試著 從local 端用 ssh 登入 remotehost 看看
$ssh remoteuser@remotehost
應該就OK了

--
Tags: Linux

All Comments

掛載外接USB硬碟

Leila avatar
By Leila
at 2009-06-04T23:11
原先硬碟格式為ntfs 用 指令fdisk分割成一區塊 指令mkfs -t reiserfs /dev/sdx1 格式化為reiserfs mount -t reiserfs -rw /dev/sdx1 /home/***/ 剛mount上去時可讀可寫 但不知為什麼 可能logout或一段時間後硬 ...

新電腦

Elizabeth avatar
By Elizabeth
at 2009-06-04T22:37
各位好, 我是一個想學linux的新手, 想組一台練習機, 學習指令列的使用 最後的目的, 能架一個網站, 作為一個成果, 想請教, 這樣需要怎樣的配備, linux的版本會選擇 CentOS-5.2-i386 預算在1萬2左右(不含螢幕) 謝謝 - ...

utunbu 9.04雙系統Grub的問題

Sarah avatar
By Sarah
at 2009-06-04T22:33
小弟有三顆實體硬碟如下: sda0 75GB NTFS (Vista x64) sda1 137.58GB NTFS sda2 16.21GB EXT4 (Ubuntu 9.04 mount:/) sda3 3.13GB EXT4 (mount:/home) sda4 980MB SWA ...

關於開機選單的問題 spfdisk grub

Candice avatar
By Candice
at 2009-06-04T21:56
剛開始玩ubuntu的新手 先說明我現在的情況 我是使用notebook 硬碟分成了一個主分割 剩下同一個邏輯磁碟區 我是先灌了xp在主分割 接著灌了windows7 rc來玩 那win 就幫我做了一個開機選單 可以選win7 or xp 之後再灌ubuntu 然後我把grub 灌在ubuntu的磁碟 那我應 ...

個人郵件還原

Xanthe avatar
By Xanthe
at 2009-06-04T20:41
我也想知道 是不是要在 postfix 或 qpopper 上做一些設定, 才能使 outlook 的 and#34;在伺服器保留郵件備份and#34; 生效呢? :?: http://img15.imgspot.com/u/06/322/23/outlook1163998356.png http://bl ...