ssh是一种远程登陆服务,比如A电脑通过网络控制B电脑。下面记录了在ubuntu下服务端和客户端的安装和使用,windows下也可以下载相关登陆工具登陆ubuntu。
服务端
安装
$ sudo apt-get install openssh-server
启动和关停
$ sudo /etc/init.d/ssh start $ sudo /etc/init.d/ssh stop $ sudo /etc/init.d/ssh restart
开机启动
打开配置文件:
$ sudo vi /etc/rc.local
在exit 0 前插入一行:
/etc/init.d/ssh start
客户端
安装
$ sudo apt-get install openssh-client
登陆格式
$ ssh -p 22 username@ip
例子
$ ssh -p 22 testuser@192.168.0.149
客户端常见错误处理
1、如果登陆出现下面错误:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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 a host key has just been changed. The fingerprint for the ECDSA key sent by the remote host is SHA256:TOI+u2ePlOHFxCvSnVAfSXo7NyJ9OUhm+upoyy8F9Vc. Please contact your system administrator. Add correct host key in /home/codbo/.ssh/known_hosts to get rid of this message. Offending ECDSA key in /home/codbo/.ssh/known_hosts:1 remove with: ssh-keygen -f "/home/codbo/.ssh/known_hosts" -R 192.168.0.149 ECDSA host key for 192.168.0.149 has changed and you have requested strict checking. Host key verification failed.
这种情况可能是之前连接个相同ip的电脑,其实上面错误信息已经给出了解决办法,执行下面命令删除掉旧的登陆信息就可以解决
$ ssh-keygen -f "/home/codbo/.ssh/known_hosts" -R 192.168.0.149
已有 594 位网友参与,快来吐槽:
发表评论