Ubuntu下安装ssh

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值