安裝ssh並設定免密
我的使用者名稱是master
1.安裝ssh(若沒安裝的話)
sudo apt-get install ssh
2.配置為可以免密碼登陸本機。
2.1檢視在master使用者下是否存在.ssh資料夾(ssh前面有.的是隱藏資料夾),輸入命令ls -a /home/master。我的沒有,所以新建個mkdir /home/master/.ssh
2.2生成私鑰和公鑰:ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
2.3把公鑰(id_dsa.pub)追加到授權的key中去:cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
3.驗證ssh是否安裝成功:ssh -version
顯示:
OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
Bad escape character 'rsion'.
則說明安裝成功
輸入命令:ssh localhost
顯示:
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is 34:69:fc:a8:92:c0:53:1e:06:1b:da:ef:44:1a:05:de.
Are you sure you want to continue connecting (yes/no)?
輸入yes,顯示:
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 12.04.1 LTS (GNU/Linux 3.2.0-29-generic-pae i686)
* Documentation: https://help.ubuntu.com/
Last login: Sun Jun 23 06:21:25 2013 from 192.168.159.1
說明安裝成功(第一次登陸時會詢問是否繼續連線,輸入yes即可連線)
實際上,在hadoop的安裝過程中,是否免密碼登陸是無關緊要的,但是如果不配置免密碼登陸,每次啟動hadoop都需要輸入密碼以登陸到每臺DataNode上。不配置免密碼登陸時,當叢集大了,就會很頭疼。