中易网

ubuntu怎么修改ssh root密码

答案:2  悬赏:20  
解决时间 2021-03-12 20:34
ubuntu怎么修改ssh root密码
最佳答案
在使用虚拟机过程中,因为时常要切换到win7下调试,所以比较麻烦。所以最近尝试在win下用SSH Secure Shell Client登陆虚拟机,为了避免反复的su切换到root,所以希望以root用户登陆。 1.首先win7安装SSH Secure Shell Client,Ubuntu下也使用apt...
全部回答
设置root密码 1 使用原密钥登陆远程主机,默认登陆用户为ubuntu 得到远程机ip 如果是aws,在ec2控制台查看一下实例的公有 ip,复制一下 cmd ssh -i 密钥 [email protected] 2 空密码不让登陆的,所以要给root一个新密码 su passwd root 输入两次新密码就可以了 end 修改/etc/ssh/sshd_config 修改 vi /etc/ssh/sshd_config 密码登陆 permitrootlogin yes strictmodes no permitemptypasswords yes passwordauthentication yes 密钥登陆 hostkey /etc/ssh/ssh_host_rsa_key hostkey /etc/ssh/ssh_host_rsa1_key hostkey /etc/ssh/ssh_host_dsa_key hostkey /etc/ssh/ssh_host_ecdsa_key hostkey /etc/ssh/ssh_host_ed25519_key rsaauthentication yes pubkeyauthentication yes authorizedkeysfile %h/.ssh/authorized_keys 如果不想一个个改,也可以复制粘贴 全文如下 #/etc/ssh/sshd_config # package generated configuration file # see the sshd_config(5) manpage for details # what ports, ips and protocols we listen for port 22 # use these options to restrict which interfaces/protocols sshd will bind to #listenaddress :: #listenaddress 0.0.0.0 protocol 2 # hostkeys for protocol version 2 hostkey /etc/ssh/ssh_host_rsa_key hostkey /etc/ssh/ssh_host_rsa1_key hostkey /etc/ssh/ssh_host_dsa_key hostkey /etc/ssh/ssh_host_ecdsa_key hostkey /etc/ssh/ssh_host_ed25519_key #privilege separation is turned on for security useprivilegeseparation yes # lifetime and size of ephemeral version 1 server key keyregenerationinterval 3600 serverkeybits 1024 # logging syslogfacility auth loglevel info # authentication: logingracetime 120 permitrootlogin yes strictmodes no rsaauthentication yes pubkeyauthentication yes authorizedkeysfile %h/.ssh/authorized_keys # don't read the user's ~/.rhosts and ~/.shosts files ignorerhosts yes # for this to work you will also need host keys in /etc/ssh_known_hosts rhostsrsaauthentication no # similar for protocol version 2 hostbasedauthentication no # uncomment if you don't trust ~/.ssh/known_hosts for rhostsrsaauthentication #ignoreuserknownhosts yes # to enable empty passwords, change to yes (not recommended) permitemptypasswords yes # change to yes to enable challenge-response passwords (beware issues with # some pam modules and threads) challengeresponseauthentication no # change to no to disable tunnelled clear text passwords passwordauthentication yes # kerberos options #kerberosauthentication no #kerberosgetafstoken no #kerberosorlocalpasswd yes #kerberosticketcleanup yes # gssapi options #gssapiauthentication no #gssapicleanupcredentials yes x11forwarding yes x11displayoffset 10 printmotd no printlastlog yes tcpkeepalive yes #uselogin no #maxstartups 10:30:60 #banner /etc/issue.net # allow client to pass locale environment variables acceptenv lang lc_* subsystem sftp /usr/lib/openssh/sftp-server # set this to 'yes' to enable pam authentication, account processing, # and session processing. if this is enabled, pam authentication will # be allowed through the challengeresponseauthentication and # passwordauthentication. depending on your pam configuration, # pam authentication via challengeresponseauthentication may bypass # the setting of "permitrootlogin without-password". # if you just want the pam account and session checks to run without # pam authentication, then enable this but set passwordauthentication # and challengeresponseauthentication to 'no'. usepam yes 生成私钥 ssh-keygen -t dsa /etc/ssh/ssh_host_dsa_key ssh-keygen -t ecdsa /etc/ssh/ssh_host_ecdsa_key ssh-keygen -t ed25519 /etc/ssh/ssh_host_ed25519_key ssh-keygen -t rsa /etc/ssh/ssh_host_rsa_key ssh-keygen -t rsa1 /etc/ssh/ssh_host_rsa1_key chmod 600 /etc/ssh/*key 复制公钥到authorized_keys cat /etc/ssh/ssh*pub>>/home/ubuntu/.ssh/authorized_keys cat /home/ubuntu/.ssh/authorized_keys >/root/.ssh/authorized_keys chmod 644 /root/.ssh/authorized_keys 使用ubuntu的私钥就可以登陆了 也可以把/etc/ssh/下的key复制粘贴过来 /etc/ssh/ssh_host_dsa_key /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ed25519_key /etc/ssh/ssh_host_rsa_key 重启远程机 就可以直接用root登陆了 使用密码 ssh [email protected] 或者使用密钥 ssh -i ssh_host_dsa_key root@ip ssh -i ssh_host_ecdsa_key root@ip ssh -i ssh_host_ed25519_key root@ip ssh -i ssh_host_rsa_key root@ip ssh -i ssh_host_rsa1_key root@ip
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
我用笔记本电脑电池做了一个移动电源,为什么
仪园饭店在什么地方啊,我要过去处理事情
大家都用过哪些家小贷
long-necked什么意思
怎么写“文明之星”和“奉献之星”的获奖感言
究极宝玉神虹龙当墓地集齐7种宝玉兽可以特殊
中国有没有一种远程控制人体的技术
请教专家们一个关于单片机无法下载程序的问题
黄河水利职业技术学院能转专业吗
谁知道天安保险车险理赔速度?我的车想来这里
中国移动通信卅铺指定专营厅地址在什么地方,
康明期发动机频繁拉缸原因?
怎样将手机话费充值到支付宝?
重庆观音桥房价
本人想纹个纹身 请大师赐教 我能纹关公或者邪
推荐资讯
森广微型汽修在哪里啊,我有事要去这个地方
彤德莱火锅NO.407怎么去啊,有知道地址的么
有谁知道昨天9月4号.东部华侨城咆哮山洪14.30
壳牌和美孚哪个适合柴油车
小说里的人物杨烨这部小说叫什么名字
沙海街/S204(路口)地址在什么地方,想过去办
从西安城南客运站坐哪路公交到西安市立新街18
中国石化常山浙西第二加油站这个地址在什么地
海风酒业地址在什么地方,想过去办事
充电头3.4A对手机有影响吗
友善带人播音稿200字
she wants to _ _your friends,too
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?