用ssh登录到服务器之后,在实际运行过程中,碰到若干问题:


No. 1. 用gedit打开文件时,出现Failed to connect to server socket

u1@cugeri:~/YQ$ gedit Tips.txt

Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused

(gedit:11343): Gtk-WARNING **: cannot open display: 

Solusion:

ssh -X u1@192.168.5.10 [note: -X 开启X11转发功能]
u1@cugeri:~/YQ$ sudo gedit Tips.txt [note: sudo 给予权限]

点击查看详细解释

啥?加了-X命令问题仍然存在。

Solusion:

ssh -Y u1@192.168.5.10 [note: -Y 信任X11转发功能]
u1@cugeri:~/YQ$ sudo gedit Tips.txt [note: sudo 给予权限]

点击查看详细解释


No. 2. 登录时出现 WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! or Permission denied, please try again.

lenovo@YQ:~$ ssh u1@192.168.5.10
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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:TYQpjubLWljkRc+9BLGFlFHt1bQxSCEQ4nCdYE4AMFk.
Please contact your system administrator.
Add correct host key in /home/lenovo/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/lenovo/.ssh/known_hosts:1
  remove with:
  ssh-keygen -f "/home/lenovo/.ssh/known_hosts" -R 192.168.5.10
ECDSA host key for 192.168.5.10 has changed and you have requested strict checking.
Host key verification failed.

网上搜了答案(错误):

sudo rm -f ~/.ssh/known_hosts

然后登录:

lenovo@YQ:~$ ssh u1@192.168.5.10
u1@192.168.5.10's password: 
Permission denied, please try again.
u1@192.168.5.10's password: 
Permission denied, please try again.
u1@192.168.5.10's password:

网上又搜了答案(错误):

sudo vim /etc/ssh/sshd_config

PermitRootLogin without-password改为PermitRootLogin yes

仍旧无效呀!??? 想起来前天有一阵电信维修停网。mmp,导致服务器和笔记本的internet address都变了。

solusion:

ifconfig

找到inet addr: ***.***.**.**一行,睁大眼睛看看是不是原来的ip。改过去按上一博客提示登录就好啦!

lenovo@YQ:~$ ssh u1@192.168.5.2
u1@192.168.5.2's password: 
Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.15.0-36-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

70 packages can be updated.
0 updates are security updates.

New release '18.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

You have new mail.
Last login: Wed Oct 31 10:55:34 2018 from 192.168.5.10
u1@cugeri:~$ 

No. 3. 不同局域网下用ssh远程登录服务器的实现方法:NAT traverse by ssh


持续更新