使用用户名密码登录
ssh username@ip_address -p port
之后系统会提示输入密码,输入后即可登录
如果不添加-p选项,则默认是22端口
密钥登陆
ssh-keygen -t rsa -P ''
-P表示密码,-P ''表示空密码
[root@localhost ~]# ssh-keygen -t rsa -P ''
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
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:
5b:ca:7e:07:9c:3a:d6:71:9b:90:ee:0c:02:4c:9a:f8 root@localhost
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| . |
| . = |
|. o o S..o |
| . . . +B . |
| E . =+ = o |
| o+o+ + |
| ..+o. |
+-----------------+
[root@localhost ~]# ssh-copy-id root@192.168.200.164
The authenticity of host '192.168.200.164 (192.168.200.164)' can't be established.
ECDSA key fingerprint is 9b:56:98:3d:c5:1f:a6:f4:a3:33:78:88:76:48:e5:ef.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.200.164's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.200.164'"
and check to make sure that only the key(s) you wanted were added.
[root@localhost ~]# ssh 192.168.200.164
Last login: Thu Apr 13 21:59:15 2017 from 192.168.200.117