【虚拟机ubuntu设置ssh】ssh连不上问题解决方法 |
您所在的位置:网站首页 › win10使用ssh连接虚拟机偶尔断开 › 【虚拟机ubuntu设置ssh】ssh连不上问题解决方法 |
转载自博客园:https:www.cnblogs.com/chenxiaomeng/,仅供自用学习记录。
首先,确保server端的ssh服务是开的(service shhd start) 然后在client端输入: ssh 【usrname】@【serverip】 (远程登录) scp 【filename】 【usrname】@【serverip】:/URL (远程传输) 常出现的问题: 1.端口失效 ssh 192.168.*.ssh: connect to host 192.168.*. port 22: No route to host 这由于server端没有开机或是网络不通(这个原因很多,最简单的是网线没有插。还有就是可能会是网卡down了等)如果是网卡down了ifup相应的网卡再试试 2.linux的ssh服务没有开启首先确保要登录的主机安装了openssh-client (ubuntu有默认安装,如果没有则输入安装命令) sudo apt-get install openssh-client 如果要使本机开放SSH服务就需要安装 openssh-server sudo apt-get install openssh-server server安装过程中可能会出现问题如下: Reading package lists… Done Building dependency tree Reading state information… Done Package openssh-server is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package openssh-server has no installation candidate重新运行以下的代码 sudo apt-get update sudo apt-get upgrade sudo apt-get install openssh-server然后确认sshserver是否启动了: ps -e |grep ssh 如果看到sshd那说明ssh-server已经启动了。 如果没有则可以这样启动: sudo /etc/init.d/ssh startssh-server配置文件位于/ etc/ssh/sshd_config,在这里可以定义SSH的服务端口,默认端口是22,你可以自己定义成其他端口号,如222。 然后重启SSH服务: sudo /etc/init.d/ssh stop sudo /etc/init.d/ssh start 然后使用以下方式登陆SSH: ssh [email protected].*. zhou为192.168.***.**机器上的用户,需要输入密码。 断开连接:exit 3.ssh到server上的时候密码是对的但是报如下信息: ssh 192.168.*.[email protected].*.'s password: Permission denied, please try again. 这个是由于如果不输入用户名的时候默认的是root用户,但是安全期间ssh服务默认没有开root用户的ssh权限解决方法: 要修改root的ssh权限,即修改 /etc/ssh/sshd_config文件中 PermitRootLogin no 改为 PermitRootLogin yes vim /etc/ssh/sshd_config找到 Authentication: LoginGraceTime 120 PermitRootLogin prohibit-password StrictModes yes改成 Authentication: LoginGraceTime 120 PermitRootLogin yes StrictModes yes然后重启服务 /etc/init.d/ssh restart 4.登录是出现如下提示:ssh [email protected].*. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the RSA host key has just been changed. The fingerprint for the RSA key sent by the remote host is 76:fb:b3:70:14:48:19:d6:29:f9:ba:42:46:be:fb:77. Please contact your system administrator. Add correct host key in /home/fante/.ssh/known_hosts to get rid of this message. Offending key in /home/fante/.ssh/known_hosts:68 RSA host key for 192.168.*. has changed and you have requested strict checking. Host key verification failed. server端密码或是其他发生改变的时候。 解决方法一般就需要删除~/.ssh/known_hosts的东西,然后再登录即可。 5.ssh [email protected]Connecting to 192.168.23.48:22… Could not connect to ‘192.168.23.48’ (port 22): Connection failed. Type `help’ to learn how to use Xshell prompt. 第一种情况: 因为防火墙的原因导致的 第1查看 service iptables status 说明当前没有开启 如果有开启的话则关闭当前的防火墙 /etc/init.d/iptables stop 之后要重启可以 service iptables start 第2查看 sudo ufw status 发现目前的系统只是支持8080端口的访问,可以将ssh的端口访问加入 ufw allow 22 加入22端口之后可以正常访问 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |