windows 通过cmd窗口ssh命令使用密码远程连接服务器(Ubuntu)

密码登录

Ubuntu 系统的默认用户名是 ubuntu,并在安装过程中默认不设置 root 帐户和密码。您如有需要,可在设置中开启允许 root 用户登录。具体操作步骤如下:

  1. 首先另辟路径登上你的基于Ubuntu的服务器

  2. 执行命令,设置root密码 sudo passwd root

  3. 输入密码,重复输入密码,返回passwd: password updated successfully说明root密码设置成功

  4. 打开sshd_config配置文件,路径/etc/ssh/sshd_config具体的ssd_config解析

  5. 找到# Authentication:修改PermitRootLogin yes

    # Authentication:
    
    #LoginGraceTime 2m
    #PermitRootLogin prohibit-password	# 禁止密码登录,只允许通过密钥登陆
    PermitRootLogin yes
    #StrictModes yes
    #MaxAuthTries 6
    #MaxSessions 10
    
  6. 修改PasswordAuthentication参数为yes,没有就添加

    # To disable tunneled clear text passwords, change to no here!
    PasswordAuthentication yes
    #PermitEmptyPasswords no
    
  7. 重启ssh服务,sudo service ssh restart。或者重启服务器,或sudo systemctl restart sshd

  8. 然后就可以通过cmd窗口命令

    ssh root@公网ip或域名	#但是域名得提前解析到公网ip
    
  9. 如果出现以下WARNNING,就把C:\\Users\\andya/.ssh/known_hosts:1下的known_hosts这个文件删掉

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @    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:W02kdKGXXmOYxdbdWRS4lj6GU0B+wBaL6VjmoiD6t6c.
    Please contact your system administrator.
    Add correct host key in C:\\Users\\andya/.ssh/known_hosts to get rid of this message.
    Offending ECDSA key in C:\\Users\\andya/.ssh/known_hosts:1	#这个路径!!!
    ECDSA host key for yanghe.life has changed and you have requested strict checking.
    Host key verification failed.
    
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值