搜集的ssh基本用法
登录
ssh user@host
如果本地用户名与远程用户名一致,登录时可以省略用户名.
ssh host
SSH的默认端口是22,也就是说,你的登录请求会送进远程主机的22端口。使用p参数,可以修改这个端口
ssh -p 2222 user@host
口令登录,如果你是第一次登录对方主机,系统会出现下面的提示
$ ssh user@host
The authenticity of host 'host (192.1168.1.116)' can't be established.
RSA key fingerprint is 58:25:d5:e5:d5:95:5c:47:58:42:45:25:34:46:55:44.
Are you sure you want to continue connecting (yes/no)?
无法确认host主机的真实性,只知道它的公钥指纹,问你还想继续连接吗?
输入yes 系统会出现一句提示,表示host主机已经得到认可。
Warning: Permanently added 'host,192.1168.1.116' (RSA) to the list of known hosts.
输入密码
Password:
登陆成功!
公钥登录,公钥传送到远程主机上面
ssh-copy-id user@host
如果不行,打开远程主机的/etc/ssh/sshd_config这个文件,检查下面几行前面”#”注释是否取掉
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
重启ssh
/etc/init.d/ssh restart