SecureCRT通过ssh服务连接Ubuntu虚拟机

1. 首先检查虚拟机有没有安装并启动ssh服务,

    ssh localhost

    出现以下提示则为未安装: 
    ssh: connect to host localhost port 22: Connection refused 
    (ssh:连接到主机本地主机端口22:连接被拒绝)

    或者用下面命令查看ssh服务是否开启:

    service ssh status  或者 /etc/init.d/ssh status 

 正常启动结果为

 

2. root权限安装openssh-server

    sudo apt-get install openssh-server

3. 安装完后查看ssh服务是否已开启

    ps -ef | grep ssh

    查看结果里有没有sshd,若没有输入下面命令启动(需要root权限)

    /etc/init.d/ssh start

( 其他命令:/etc/init.d/ssh [stop|restart] )

4. 可修改ssh服务的默认端口,打开ssh配置文件sshd_config (ssh_config是openssh-client的配置文件,sshd_config是server的)

    vim /etc/ssh/sshd_config

    找到#port 22,可以取消注释,然后修改22为自己想要设置的端口号,但要确认该端口号没有被占用。

5. 此时即可用SecureCRT连接登录,使用普通用户名和密码登录。

    但我想直接用root用户登录,尝试登录时发现总是提示错误:Password authentication failed, Please verify that the username and password...

    我确信我的密码是正确的,经过查找发现sshd_config中有这个设置PermitRootLogin,默认值是prohibit-password,禁止了Root的登录权限

       

    man sshd_config查看详细说明:

6. 原因找到了,那么修改sshd_config中 PermitRootLogin yes

         

    然后重启ssh服务:/etc/init.d/ssh restart

即可在SecureCRT用root用户和密码连接Ubuntu。

猜你喜欢

转载自www.cnblogs.com/mdh-1023/p/12191008.html