文章1、linux
生成密鑰:windows
在Linux主機(ssh客戶端),
經過ssh-keygen在創建SSH keys
# ssh-keygen -t rsa (連續三次回車,即在本地生成了公鑰和私鑰,不設置密碼)
將在linux主機的當前用戶HOME目錄下的.ssh目錄,生成id_rsa.pub和id_rsa,其中,id_rsa是密匙,id_rsa.pub是公匙,你須要將id_rsa.pub上傳(ssh服務端,也就是裝有winsshd的windows機器)
可以使用下面命令
cd ~/.ssh
scp id_rsa.pub Administrator@192.168.0.1:/d:/dataoracle
2.將公匙導入到winsshd
Open easy setting–>Virtual accounts
點add按鈕,,,輸入一個名字,好比codeif,在列表中0 keys後的編輯按鈕,導入剛纔的公匙之後就能夠不用輸入密碼,linux就能夠經過scp命令從裝有winsshd的機器上獲取文件了ssh
附windows和linux互傳文件的方法:ide
爲了進行系統維護操做,有時須要再windows和linux或Unix系統之間互傳文件,雖然有不少工具能夠實現該功能,但我仍是以爲命令行來的方便快捷,起初使用linux的scp命令,老是不成功,網上也沒有相關介紹,通過幾回努力以後,終於成功的摸索出了scp命令在寫windows的路徑時的寫法,因而立刻下了出來,與你們分享:工具
從linux系統複製文件到windows系統:scp /Oracle/a.txt administrator@192.168.3.181:/d:/spa
在linux環境下,將windows下的文件複製到linux系統中:scp administrator@192.168.3.181:/d:/test/config.ips /oracle.net
請注意:由於windows系統自己不支持ssh協議,因此,要想上面的命令成功執行,必須在windows客戶端安裝ssh for windows的客戶端軟件,好比winsshd,使windows系統支持ssh協議才行。命令行
http://www.codeif.com/topic/564code
文章2、
http://blog.163.com/lgh_2002/blog/static/44017526201011333227161/
ssky-keygen + ssh-copy-id 無密碼登錄遠程LINUX主機【OK】
2010-12-03 15:32:27| 分類: Linux/Unix |字號 訂閱
使用下例中ssky-keygen和ssh-copy-id,僅需經過3個步驟的簡單設置而無需輸入密碼就能登陸遠程Linux主機。
ssh-keygen 建立公鑰和密鑰。
ssh-copy-id 把本地主機的公鑰複製到遠程主機的authorized_keys文件上。
ssh-copy-id 也會給遠程主機的用戶主目錄(home)和~/.ssh, 和~/.ssh/authorized_keys設置合適的權限 。
步驟1: 用 ssh-key-gen 在本地主機上建立公鑰和密鑰
ligh@local-host$ ssh-keygen -t rsa
Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):[Enter key]
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Pess enter key]
Your identification has been saved in /home/jsmith/.ssh/id_rsa.
Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub.
The key fingerprint is: 33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9
ligh@local-host
步驟2: 用 ssh-copy-id 把公鑰複製到遠程主機上
ligh@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.3
ligh@remote-host‘s password:
Now try logging into the machine, with ―ssh ?remote-host‘‖, and check in:
.ssh/authorized_keys to make sure we haven‘t added extra keys that you weren‘t expecting.
[注: ssh-copy-id 把密鑰追加到遠程主機的 .ssh/authorized_key 上.]
步驟3: 直接登陸遠程主機
ligh@local-host$ ssh remote-host
Last login: Sun Nov 16 17:22:33 2008 from 192.168.1.2
[注: SSH 不會詢問密碼.]
ligh@remote-host$
文章3、 本身添加的一些信息
在Windows 下的winsshd 添加本身 Linux 客戶機的時候共有兩處添加點分別是:
一、Open easy setings ->Windows accounts -> add -> administrator 用戶 ->Public keys imported ->import -> id_rsa.pub就行 // 其實只須要添加這一個就能夠了
二、Open easy seting ->Virtual accounts->add -> administrator 用戶 ->Public keys imported ->import -> id_rsa.pub就行