温馨提示×

ubuntu securecrt如何连接服务器

小樊
36
2025-12-10 07:55:43
栏目: 云计算

Ubuntu 上使用 SecureCRT 连接服务器的完整步骤

一 准备与安装

  • Ubuntu 客户端安装 SecureCRT(原生 Linux 版):从官方下载 .deb 包后执行安装,例如:sudo dpkg -i scrt-9.2.3-2829.ubuntu20-64.x86_64.deb;若提示缺少依赖,运行 sudo apt-get -f install 补齐依赖。也可使用 Wine 运行 Windows 版安装包(sudo apt install wine,然后 wine SecureCRT_Installer.exe)。
  • Ubuntu 服务器安装并启动 OpenSSH 服务:sudo apt-get update && sudo apt-get install openssh-server;sudo systemctl start ssh;sudo systemctl enable ssh;确认状态:sudo systemctl status ssh。
  • 获取服务器 IP 地址:在服务器执行 ip addr(或 ifconfig)查看内/外网 IP。

二 在 SecureCRT 中新建并连接会话

  • 打开 SecureCRT → File → New Session(或 Quick Connect)。
  • 配置会话参数:
    • Protocol:SSH2
    • Hostname:服务器 IP
    • Port:22(如修改过 SSH 端口,填对应端口)
    • Username:登录用户名
  • 首次连接会提示 主机密钥指纹,核对后选择接受并保存。
  • 选择密码或密钥认证方式登录:
    • 密码登录:输入用户密码。
    • 密钥登录(推荐):在会话属性的 Authentication 中取消 Password,选择 PublicKey,指定私钥文件(如 id_rsa),必要时在服务器将公钥(~/.ssh/authorized_keys)配置好并确保权限正确。

三 常见问题与快速排查

  • 连接被拒绝或超时:
    • 服务器侧确认 SSH 已运行:sudo systemctl status ssh;必要时 sudo systemctl restart ssh。
    • 防火墙放行:sudo ufw allow 22/tcp(或临时测试 sudo ufw disable)。
    • 云服务器安全组/NACL 放行 TCP 22 端口。
    • 端口不对或监听异常:ss -tulpen | grep :22 或 netstat -tuln | grep sshd。
  • 算法不兼容报错(如 No compatible hostkey/key exchange method):
    • 客户端:在 Session Options → Connection → SSH2 中勾选/启用常用的 Host Key AlgorithmsKex Algorithms(如 ecdsa-sha2-nistp256、diffie-hellman-group14-sha1 等)。
    • 服务器:编辑 /etc/ssh/sshd_config,按需添加例如:
      • HostKeyAlgorithms=+ssh-rsa,ssh-dss
      • KexAlgorithms=curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1
        修改后重启 SSH:sudo systemctl restart ssh。
  • 中文乱码:Options → Session Options → Terminal → Appearance → Character encoding 选择 UTF-8

四 实用优化与文件传输

  • 会话优化:适当增大回滚缓冲区(Options → Session Options → Terminal → Emulation),提升长输出查看体验。
  • 文件传输:
    • 服务器安装 lrzsz:sudo apt-get install lrzsz。
    • 在 SecureCRT 的 Session Options → X/Y/Zmodem 中设置上传/下载目录。
    • 上传:在终端输入 rz;下载:输入 sz 文件名。

0