赞
踩
1、安装ssh
root@ubuntu:~# apt-get install ssh
2、ssh免密码登录
root@ubuntu:~# ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
显示内容如下:
Generating public/private dsa key pair.
Created directory '/root/.ssh'.
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
d4:06:ba:59:c4:9e:63:c4:e8:d7:c7:1d:87:79:e1:74 root@ubuntu
The key's randomart image is:
+--[ DSA 1024]----+
| +o =E|
| .o+o * +|
| ..oooo. . = |
| .=*.. o . |
| ooS. . |
| |
| |
| |
| |
+-----------------+
root@ubuntu:~# cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
3、验证不用密码是否能ssh到localhost
root@ubuntu:~# ssh localhost
第一次可能会出现下面信息:
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is aa:f9:5d:41:a0:21:ca:49:9e:52:32:c8:4a:7d:58:63.
Are you sure you want to continue connecting (yes/no)?
输入yes即可出现:
Welcome to Ubuntu 11.04 (GNU/Linux 2.6.38-8-generic x86_64)
* Documentation: https://help.ubuntu.com/
--------------------------------------------------------
OK!成功!
可以用who命令查看状态:
root@ubuntu:~# who
4、检查是否安装了ssh
root@ubuntu:~# dpkg --list|grep ssh
显示内容如下:
ii openssh-client 1:5.8p1-1ubuntu3 secure shell (SSH) client, for secure access to remote machines
ii openssh-server 1:5.8p1-1ubuntu3 secure shell (SSH) server, for secure access from remote machines
ii ssh 1:5.8p1-1ubuntu3 secure shell client and server (metapackage)
ii ssh-askpass-gnome 1:5.8p1-1ubuntu3 interactive X program to prompt users for a passphrase for ssh-add
ii ssh-import-id 2.4-0ubuntu1 securely retrieve an SSH public key and install it locally
5、检查ssh是否启动
root@ubuntu:~# ps -ef|grep ssh
显示内容如下:
root 1653 1615 0 09:04 ? 00:00:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session gnome-session --session=ubuntu
root 2990 1 0 09:42 ? 00:00:00 /usr/sbin/sshd -D
root 3061 1948 0 09:52 pts/0 00:00:00 ssh localhost
root 3062 2990 0 09:52 ? 00:00:00 sshd: root@pts/2
root 3217 3153 0 09:54 pts/2 00:00:00 ssh localhost
root 3218 2990 0 09:54 ? 00:00:00 sshd: root@pts/3
root 3370 3284 0 10:00 pts/3 00:00:00 grep --color=auto ssh
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。