SecureCRT连接Linux

在将SecureCRT连接Linux上时遇到一些问题,记录如下。

第一步,我们要在在linux上安装openssh-server服务,并确认打开了22监听端口。在linux上操作命令如下:

apt-get install openssh-server

以上命令是安装openssh-server。但是报错了

bash: apt-get: 未找到命令...

原因与解决方案参见我的另一篇文章:bash: apt-get: 未找到命令...

PS,yum -y update这个命令不要轻易执行,不然会更新很多东西,你就什么都别干了。

第二步,配置SecureCRT

本机上连接的话ip地址是192.168.1.100(假设如此),也可以自己查看自己linux上的ip地址,命令如下:

ifconfig

此时报错了:

The remote system refused the connection.

有人说是openssh安装不完整的缘故,可能是openssh-client没有安装,如果要确认sshserver是否启动,执行命令:

ps -e | grep ssh

结果如下:

46328 ?        00:00:00 sshd

只有sshd,没有sshd-agent,说明安装确实不完整,那就是openssh-client没有安装,安装命令如下:

yum -y install openssh-clients

ps,网上的说法都是:yum -y install openssh-client,也就是最后没有s,实际上,没有s安装会报错的,报错如下:

未找到匹配的参数: openssh-client
错误:没有任何匹配: openssh-client

以上是在root用户中操作的,如果是在没有管理员权限的用户下操作,命令如下:

sudo yum -y install openssh-clients

但是安装之后再检查还是之前的样子,就是一直没有ssh-agent。继续执行命令:

eval  ssh-agent

SSH_AUTH_SOCK=/tmp/ssh-EstTZTBbrrzw/agent.165125; export SSH_AUTH_SOCK;
SSH_AGENT_PID=165126; export SSH_AGENT_PID;
echo Agent pid 165126; 

看样子这次才是真正安装好了,然后再次使用命令去查看:

ps -e | grep ssh

得到的结果是:

163732 ?        00:00:00 sshd
 165126 ?        00:00:00 ssh-agent

这次终于有ssh-agent了。

但是连接ssh之后还是报之前的错误,即:

The remote system refused the connection.

是否是需要重启ssh-server呢?试一试!

重启之后就ok了!搞定!

ps,本人级是centos8!在其他类型的linux虚拟机上命令可能有所不同,但是以上命令是本人亲测可行并最终解决了问题的!

最后,设置ssh开机启动:

systemctl enable sshd

还有一个问题,就是为什么使用127.0.0.1地址不能直接访问呢?还是报错:

The remote system refused the connection.

个人猜测是,默认拒绝使用127.0.0.1这个本地ip进行访问!

实际上,如果通过SecureCRT访问的话,是有这个错误的,但是,如果你通过linux的来访问ssh的话会有提示,访问命令如下:

ssh localhost

警告如下:

The authenticity of host 'localhost (::1)' can't be established.
ECDSA key fingerprint is SHA256:Hgb4yMJKUEfgD7Vr8K07C3vijyAbOewERxxVtjzEXkU.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
xxx@localhost's password: 
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Sun Nov 28 02:09:36 2021

以上第五行的xxx指的是用户名。以上警告信息什么意思呢?

无法建立主机“localhost(::1)”的真实性。

ECDSA密钥指纹为SHA256:Hgb4yMJKUEfgD7Vr8K07C3vijyAbOewERxxVtjzEXkU。

是否确实要继续连接(是/否/[fingerprint])?对

警告:已将“localhost”(ECDSA)永久添加到已知主机列表中。

xxx@localhost的密码:

使用以下命令激活web控制台:systemctl enable--now caffick.socket

 很好,那我们就激活它:

systemctl enable --now caffick.socket

提示如下:

==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files ====
Authentication is required to manage system service or unit files.
Authenticating as: root
Password: 

那我们究竟输入密码,之后提示:

==== AUTHENTICATION COMPLETE ====
Failed to enable unit: Unit file caffick.socket does not exist.

 文件不存在,我。。。

先到这里吧,回头再解决这个问题!晚安!

新的一天,继续这个问题!

又遇到另一个问题,需要修改 /etc/ssh/ssh_config这个文件,但是修改之后不让保存,意思是只读的,但是文件权限上命名是可以修改的。这就奇怪了!

-rw-r--r--. 1 root root       1770 10月 26 21:10 ssh_config

需要赋权?网友给出的思路是,不使用vim这个命令,换一个:

gedit /etc/ssh/ssh_config

执行命令后,又报错:

(gedit:171899): GLib-GIO-CRITICAL **: 06:31:34.715: g_dbus_proxy_new_sync: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

(gedit:171899): dconf-WARNING **: 06:31:34.892: failed to commit changes to dconf: 连接已关闭

(gedit:171899): dconf-WARNING **: 06:31:34.892: failed to commit changes to dconf: 连接已关闭
Error creating proxy: 连接已关闭 (g-io-error-quark, 18)
Error creating proxy: 连接已关闭 (g-io-error-quark, 18)
Error creating proxy: 连接已关闭 (g-io-error-quark, 18)
Error creating proxy: 连接已关闭 (g-io-error-quark, 18)
Error creating proxy: 连接已关闭 (g-io-error-quark, 18)

(gedit:171899): dconf-WARNING **: 06:31:35.643: failed to commit changes to dconf: 连接已关闭

(gedit:171899): dconf-WARNING **: 06:31:35.646: failed to commit changes to dconf: 连接已关闭

(gedit:171899): dconf-WARNING **: 06:31:35.646: failed to commit changes to dconf: 连接已关闭

切换回fangdake用户:

su fangdake

执行命令:

sudo gedit /etc/ssh/ssh_config

输入密码后,报错:

Unable to init server: 无法连接:拒绝连接

(gedit:172063): Gtk-WARNING **: 06:32:20.031: cannot open display:

解决不了。

又看到一篇帖子,解决xhost: unable to open display,按照上面进行操作,第一步就出了问题:

vncserver

报错如下:

[root@localhost ssh]# vncserver
bash: vncserver: 未找到命令...
安装软件包“tigervnc-server”以提供命令“vncserver”? [N/y] 

那就输入y开始安装。安装完毕之后,给出了很多警告,比如:

xauth:  file /root/.Xauthority does not exist

New 'localhost.centOS8:1 (fangdake)' desktop is localhost.centOS8:1

重新执行vncserver命令,警告如下:

WARNING: vncserver has been replaced by a systemd unit and is about to be removed in future releases.
Please read /usr/share/doc/tigervnc/HOWTO.md for more information.

New 'localhost.centOS8:2 (fangdake)' desktop is localhost.centOS8:2

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.centOS8:2.log
 

不管它继续执行,上面帖子中说的命令:

export DISPLAY=localhost:1

没什么问题,再继续执行:

xhost +

报错:


xhost:  unable to open display "localhost:1"

GG思密达!走到这,几乎吐了!

至于上面查看的文章中的其他方法,就不再尝试了,到此为止,也不影响自己敲一些命令了,干一些事情了!

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

北冥牧之

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值