Setting up SSH for a Hadoop cluster

Setting up SSH for a Hadoop cluster

When setting up aHadoop cluster, you’ll need to designate one specific node as the master node.We need to define a means for the master node to remotely access every node inyour cluster. Hadoop uses pasphraseless SSH for this purpose. SSH utilizesstandard public key cryptography to create a pair of keys for user verification– one public, one private. The public key is stored locally on every node inthe cluster, and the master node sends the private key when attempting toaccess a remote machine. With both pieces of information, the target machinecan validate the login attempt.

We’ve been speakingin general terms of one node accessing another; more precisely this access isfrom a user account on one node to another user account on the target machine.For Hadoop, the accounts should have the same username on all of the nodes, andfor security purpose we recommend it being a user-level account. This accountis only for managing your hadoop cluster. Once the Cluster daemons are up andrunning, you’ll be able to run your actual MapReduce jobs from other accounts.

Check whether SSHis installed on your nodes, if not please install OpenSSH via a Linux packagemanager or by downloading the source directly.

$ which ssh

/usr/bin/ssh

$ which ssd

/usr/bin/which: nossd in(/usr/kerberos/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin)

$ which ssh-keygen

/usr/bin/ssh-keygen

Having verifiedthat SSH is correctly installed on all nodes of the cluster, We use ssh-keygenon the master node to generate an RSA key pair. Be certain to avoid entering apassphrase, or you’ll have to manually enter that phrase every time the masternode attempts to access another node.

$ ssh-keygen -t rsa

Generating 2048-bitrsa key pair

4 .oOo.oOo.oOO

Key generated.

2048-bit rsa,yj70978@retailvm1d, Mon Jul 22 2013 21:06:38 -0400

Passphrase :

Again :

Key is stored withNULL passphrase.

(You can ignore the following warning if youare generating hostkeys.)

This is not recommended.

Don't do this unless you know what you'redoing.

If file system protections fail (someone canaccess the keyfile),

or if the super-user is malicious, your keycan be used without

the deciphering effort.

Private key savedto /home/yj70978/.ssh2/id_rsa_2048_a

Public key saved to/home/yj70978/.ssh2/id_rsa_2048_a.pub

$ ls -rlt/home/yj70978/.ssh2/id_rsa_2048_a

-rw------- 1yj70978 retailfi 1539 Jul 22 21:07 /home/yj70978/.ssh2/id_rsa_2048_a

$ cat /home/yj70978/.ssh2/id_rsa_2048_a

---- BEGIN SSH2ENCRYPTED PRIVATE KEY ----

Subject: yj70978

Comment:"2048-bit rsa, yj70978@retailvm1d, Mon Jul 22 2013 21:06:38 -\

0400"

P2/56wAAA+wAAAA1aWYtbW9kbntzaWdue3JzYS1wa2NzMS1zaGExfSxlbmNyeXB0e3JzYS

1wa2NzMS1ub25lfX0AAAAEbm9uZQAAA58AAAObAAAAEQEAAQAAB/oC01cYvh8cNTVtBELB

azF4B2MT2tpf0MWvA0W2KEho5G3O/TnjOocBRpdRn/yDLJieqinxzBpX9rYumP0/So3FIF

VUUd0TyLEj9CikIjVQWj0KUvNKdjsDzujiWOEpfe0vUMkqosc1GUsdIDXaBAA/LIAuTQjF

dlsfYp/OcwOFyRm4+v3lwJqWT4hedPLhZmqNgfiXOehofe1T2B5W4d/+zJ1Y2BCk9Nrak+

bJGM+Za+v1HfOgxNY+XJCpBdxb0GA9Pt8VvGjSi3liQkM9LEWGk9lxUXtzD2lsaDImmwcD

WhJ/FJVV+CNirFcSKN5Z/a8BhGa0MQFRww6hKECJRet1AAAIAKosmjEkUBCzLjPrFjwitp

zOCF6OsuAACfyyLq6jex7R78mBt0FhuezZXIvkvgxCS1gNoacBU7p0fK5d1Nte3NUC5B5k

yKuvIcEtlX8zMgu8aqA1ZDMETr3+C6qfyBiQ690sxfOEsBnW4T2Yo1KAbylOisFuyMq+dh

35nV2hLzNSVLRpiTkZniMYPQHe7o/Kj0zSQtBJNtTAgyc4JkxThYKHEdJOfZ0Zah9hVrqV

wKq2Rwf4eWmZjDABD9fzAPQOVljyaVlAQf3/m4sK5eAX1QbxPsuEUNJ4p/W/SCPaNyZYZD

UlSoEOYueWkHY/yVD5labPLUgFg3p00pUPEtjt/6sAAAP9GTPVWw+wvnbn8aKIRZ6pJpn+

zurN/c8j7wi0hT+63+UShUXO59/EadI5THTlEyB1vVBF78iuoZZfB6t4s3p4dlk/Ke0CxH

Xn81ZJy6r4kd5VhZv2fEKOjq03aewONRX1K4GXbD23KqwokVgIQ9YsJ9A187hbBz8S1N2e

XqP499wAAAQAwUumdnfKNCrr0+a5kwyEvsW85SqgDnVOeP1On1garxE6O5EVYbrlRpgk+O

kDMj7x23LwT9VnZqFcmEO8cpuo3csUzMAd0cX3hkod6RKZ/H1btrEmpzkvFA2Kf7FX3D5i

uKKq5pWykEM5fZjvXe1NbFKOCXytkqnMKJ120Bm84IUAAAQA4WDUlumoGtM/vOZLge9DyW

jO1/lfr7WCoPCFne5APOVLtGMo/xlBFVmnPrnJ6deq2EMk7IRI9ru9SB1TDNV1ktXUH6af

vR6r6vhQbHytjnd1nDeiS3xODS+ePlGwH8RgWzIU+X3uOgsKNJW7Q2OqC3uGcyIGshhc+b

9lXDop7m8=

---- END SSH2ENCRYPTED PRIVATE KEY ----


Albeit a bit tedious,you’ll next need to copy the public key to every slave node as well as themaster node:

Scp ~/.ssh/d_rsa.pubhadoop-user@target:~/master_key

Manually log in tothe target node and set the master key as an authorized key (or append to thelist of authorized keys if you have others defined).

After generatingthe key, you can verify it’s correctly defined by attempting to log in to thetarget node from the master:

$ ssh retailvm1d

You are authorizedto use this System for approved business purposes only.

Use for any otherpurpose is prohibited. All transactional records, reports,

email, software andother data generated by or residing upon this System,

to the extentpermitted by local law, are the property of Citigroup Inc.

or one of itssubsidiaries or their affiliates

(individually orcollectively ' Citigroup ') and may be used by Citigroup

for any purposeauthorized and permissible in your country of work.

Activities on thisSystem are monitored to the extent permitted by local law.

PAM Authentication

Password:

Last login: Mon Jul22 2013 07:15:29 -0400 from APACCNSHZJW2594.apac.nsroot.net


Change JAVA_HOME inhadoop-env.sh.

The standalone modeis the default mode for Hadoop. When you first uncompress the Hadoop source package,it’s ignorant of your hardware setup. Hadoop chooses to be conservative andassumes a minimal configuration.

How to use SFTP (with client validation - public key authentication) The topic How to use SFTP (with client validation - password authentication) discusses the simplest form of client authentication, via password. In public key authentication, SSH clients and servers authenticate each other via public/private key pairs. Each must have access to their own private key, and they must have access to each other's public key (unless server validation is disabled). You should ensure that the server's public keys are loaded by the client as described in How to use SFTP (with server validation - known hosts), or you may want to switch off server validation to get started. The client's public key must be registered with the SSH server, typically by copying it into the server's authorized_keys file. The client's private key is loaded via SSHFTPClient's setAuthentication method before calling connect, supplying the full path of the private key file, the SSH username and the passphrase of the private key file: ftp.setAuthentication("C:\\myhome\\.ssh\\id_rsa", username, passphrase); Both DSA and RSA keypairs can be used. There are no formal standards for SSH private key files, however three main formats are in common use. All are supported by edtFTPj/PRO (PuTTY since version 1.5.7). Private Key Type Start of key OpenSSH -----BEGIN DSA PRIVATE KEY----- SSH.com ---- BEGIN SSH2 ENCRYPTED PRIVATE KEY ---- PuTTY PuTTY-User-Key-File-2: The format is automatically detected when the file is loaded. Note that earlier versions of edtFTPj/PRO (prior to 1.5.7) do not support PuTTY keys, but they can be easily converted into SSH.COM or OpenSSH formats via PuTTYgen. The PuTTYgen.exe utility can be freely downloaded from here. It is a simple GUI application that can generate keypairs, and import and export keys in various formats. On the File menu item, select Load Private Key and load your PuTTY private key file. You can optionally enter your key's passphrase (which is advisable – otherwise the converted key will be saved without a passphrase, which is insecure). Then via Conversions -> Export OpenSSH key you can export your private key to another file in OpenSSH format (similarly for ssh.com format). The other authentication method, keyboard-interactive authentication, is discussed in How to use SFTP (with client validation - keyboard-interactive authentication).
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值