SSH 配置

来源:互联网 发布:禅城数据便民服务中心 编辑:程序博客网 时间:2024/06/06 01:33



转自 http://blog.csdn.net/lpxuan151009/article/details/6558731

--设置ssh

root@hadoop1:/opt/hadoop/conf# ps -e |grep ssh
 1297 ?        00:00:00 ssh-agent
root@hadoop1:/opt/hadoop/conf# ssh localhost
ssh: connect to host localhost port 22: Connection refused

root@hadoop1:/opt/hadoop/conf# sudo apt-get install openssh-server
正在读取软件包列表... 完成
正在分析软件包的依赖关系树      
正在读取状态信息... 完成      
将会安装下列额外的软件包:
  ssh-import-id
建议安装的软件包:
  rssh molly-guard openssh-blacklist openssh-blacklist-extra
下列【新】软件包将被安装:
  openssh-server ssh-import-id
升级了 0 个软件包,新安装了 2 个软件包,要卸载 0 个软件包,有 171 个软件包未被升级。
需要下载 317 kB 的软件包。
解压缩后会消耗掉 913 kB 的额外空


root@hadoop1:/opt/hadoop/conf# sudo /etc/init.d/ssh start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service ssh start

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start ssh
root@hadoop1:/opt/hadoop/conf# ps -e |grep ssh
 1297 ?        00:00:00 ssh-agent
 2548 ?        00:00:00 sshd

--设置ssh不需输入密码登录
root@hadoop1:/opt/hadoop/conf# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
c0:71:4e:38:4e:42:cb:cb:f2:32:52:16:6a:08:a7:66 root@hadoop1
The key's randomart image is:
+--[ RSA 2048]----+
|   .. ..o        |
|   ..o+=         |
|. o o+o..        |
|o+ o ...         |
|+E+ o   S        |
|+o o             |
|. o .            |
| . o             |
|                 |
+-----------------+


root@hadoop1:~/.ssh# cat id_rsa
-----BEGIN RSA PRIVATE KE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0cqcp6/ukCgYB+m5avd1p0DmqxrVzLaTmu
e67P4n+G/JnqMi8w71BoaemHb8RtqjSADgz36TSQGJ+LV30V6QvnMRuf/5TIjUmB
rsXBZeX6mlLejM8iQtNJnXjtJc4EHOgT9xzTNsCCjlX9g+ZZeiYmUfRMGBnrp8xt
kp1T31P2W73a9diA7M+RdQKBgGbMEJjIvOjrxgCNImreAFp61EJbCXYkg+qsWbJr
IWuMquQHyNLCvLm/D6DLVnNhUJw4NPdrcMpdAyWHoaAp9re13cZ688GFcj6LKsWS
3w6gGNah8Yu/CNwVU+oavdsi2jR4MAK2o9gG9Hi/SnLAHVkQh9phyfD8OXR52Qk6
J29xAoGBALKMgnHdvyRLR8V2w0R9wwxyJtw51jAsS2TUMq0kvweNjE3lGO8zL3tu
xspIIC1VIxBt6BBZ/Hyc+jdvX+ExxZnd3z1piVBdwpN6iNxp6TDklAwL2LCoJBhU
KyxKkmeKAZ8Tr+M7jnmQDfkFYxU6vzPutmFI7Zi3qVP1bxFEZKXT
-----END RSA PRIVATE KEY-----


root@hadoop1:~/.ssh# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
root@hadoop1:~/.ssh# cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsEgPVWfHhWwxlycHOT8hcPfdMiczVLfyzxGEFV/oJ4ksKMzzfhTP9UzjkE4cVu3dA0HIcjjDtBozODSt44KIfed1j1V++di0+NFwjZra/SVGFbyfCbLy8DUy+6CLm+IhaJkxLDM9bFyPR9ovJqm2oixK/dQUl2DDZ2/vyv2sqZPfqSnz5goFju6zrX2+ELSsNr9whClMQl24ID/58RQV1jN9VYJgBidKKP4/AV1XFSZqx4vXJd0+O88HuZjROyIBFgEg2DLX3wc2a2XoM9BTkkw+uQEEcKNQSbFpWWmt28kZPEBqMOZPrKYa+INDPrgIbVGw8ZlnhyhPm8TMNwE6t root@hadoop1

--test
root@hadoop1:~/.ssh# ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is e8:0c:77:fc:b5:1a:76:46:e1:97:ec:e0:d2:ae:b1:cd.
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 11.04 (GNU/Linux 2.6.38-8-generic i686)

 * Documentation:  https://help.ubuntu.com/


The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
原创粉丝点击