使用Desktop 版ubuntu 16.04.3 LTS 做云服務(wù)器的小坑

家里一臺2011年的老機(jī)器(Acer x3960承匣,i5-2300, 8G RAM, 120G SSD)放了很久沒有用戴卜,現(xiàn)在突然有需求在墻外部署一臺機(jī)器給國內(nèi)的小伙伴用颤殴。這機(jī)器老歸老杭跪,比t2.micro還是強(qiáng)得多通惫。收拾一下茂翔,裝個ubuntu準(zhǔn)備接客,發(fā)揮余熱履腋。

因為放在家里珊燎,用電視當(dāng)顯示器,想著哪天沒事自己還會在本地用一下遵湖,再加上那么多年和CDNS悔政、SNPS廝混的X window情節(jié),就裝了個桌面版ubuntu延旧。

安裝沒有問題谋国,配置上線也沒有問題,裝上ZeroTier迁沫,加入私網(wǎng)芦瘾,不用在費(fèi)心去做uPnP的路由器端口映射打洞。

上線后需要解決幾個問題:

  1. 開通ssh服務(wù)集畅,加入ssh key近弟。略過
  2. 修改suder
    sudu visudo
    加入下面這一行
    ubuntu ALL=(ALL) NOPASSWD: ALL
    參考 https://askubuntu.com/questions/147241/execute-sudo-without-password
  3. 奇怪的密碼登錄
    做完上面兩步,遠(yuǎn)程可以正常ssh免密碼登錄挺智,第一次用ansible playbook配置環(huán)境也全部成功祷愉。
    但是,日常使用卻時不時提示輸入密碼,很奇怪二鳄。有時要求輸入赴涵,有時直接進(jìn)去。自己用也就算了订讼,小伙伴們用起來很難受髓窜,而且還有ansible呢。
    開始debug:
    ssh 登錄時使用-v 選項躯嫉,打印log纱烘,(敏感信息略過)
$ ssh -v ubuntu@10.10.10.10
OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 53: Applying options for *
debug1: Connecting to 10.10.10.10 [10.10.10.10] port 22.
debug1: Connection established.
debug1: identity file /Users/perebor/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/perebor/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/perebor/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/perebor/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/perebor/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/perebor/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/perebor/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/perebor/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 10.10.10.10:22 as 'ubuntu'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
debug1: Host '10.10.10.10' is known and matches the ECDSA host key.
debug1: Found key in /Users/perebor/.ssh/known_hosts:66
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/perebor/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /Users/perebor/.ssh/id_dsa
debug1: Trying private key: /Users/perebor/.ssh/id_ecdsa
debug1: Trying private key: /Users/perebor/.ssh/id_ed25519
debug1: Next authentication method: password
ubuntu@10.10.10.10's password:

發(fā)現(xiàn)問題是本地ssh client會使用不同的key嘗試登錄杨拐,但是三次以后服務(wù)器就返回提示輸入密碼祈餐。
因為服務(wù)器上sshd里面有密碼登錄這個選項。那我們關(guān)上他就好了哄陶。

/etc/ssh/sshd_config 里面帆阳,把PasswordAuthentication改成no

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication no

然后重啟ssh服務(wù)

sudo service ssh restart

再次登錄屋吨,直接進(jìn)入蜒谤。

$ ssh -v ubuntu@10.10.10.10
OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 53: Applying options for *
debug1: Connecting to 10.10.10.10 [10.10.10.10] port 22.
debug1: Connection established.
debug1: identity file /Users/perebor/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/perebor/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/perebor/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/perebor/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/perebor/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/perebor/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/perebor/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/perebor/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 10.10.10.10:22 as 'ubuntu'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
debug1: Host '10.10.10.10' is known and matches the ECDSA host key.
debug1: Found key in /Users/perebor/.ssh/known_hosts:66
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/perebor/.ssh/id_rsa
debug1: Server accepts key: pkalg rsa-sha2-512 blen 535
debug1: Authentication succeeded (publickey).
Authenticated to 10.10.10.10 ([10.10.10.10]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.10.0-33-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

0 packages can be updated.
0 updates are security updates.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市至扰,隨后出現(xiàn)的幾起案子鳍徽,更是在濱河造成了極大的恐慌,老刑警劉巖敢课,帶你破解...
    沈念sama閱讀 219,039評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件阶祭,死亡現(xiàn)場離奇詭異,居然都是意外死亡直秆,警方通過查閱死者的電腦和手機(jī)濒募,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,426評論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來圾结,“玉大人瑰剃,你說我怎么就攤上這事◇菀埃” “怎么了晌姚?”我有些...
    開封第一講書人閱讀 165,417評論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長歇竟。 經(jīng)常有香客問我挥唠,道長,這世上最難降的妖魔是什么途蒋? 我笑而不...
    開封第一講書人閱讀 58,868評論 1 295
  • 正文 為了忘掉前任猛遍,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘懊烤。我一直安慰自己梯醒,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,892評論 6 392
  • 文/花漫 我一把揭開白布腌紧。 她就那樣靜靜地躺著茸习,像睡著了一般。 火紅的嫁衣襯著肌膚如雪壁肋。 梳的紋絲不亂的頭發(fā)上号胚,一...
    開封第一講書人閱讀 51,692評論 1 305
  • 那天,我揣著相機(jī)與錄音浸遗,去河邊找鬼猫胁。 笑死,一個胖子當(dāng)著我的面吹牛跛锌,可吹牛的內(nèi)容都是我干的弃秆。 我是一名探鬼主播,決...
    沈念sama閱讀 40,416評論 3 419
  • 文/蒼蘭香墨 我猛地睜開眼髓帽,長吁一口氣:“原來是場噩夢啊……” “哼菠赚!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起郑藏,我...
    開封第一講書人閱讀 39,326評論 0 276
  • 序言:老撾萬榮一對情侶失蹤衡查,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后必盖,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體拌牲,經(jīng)...
    沈念sama閱讀 45,782評論 1 316
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,957評論 3 337
  • 正文 我和宋清朗相戀三年筑悴,在試婚紗的時候發(fā)現(xiàn)自己被綠了们拙。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,102評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡阁吝,死狀恐怖砚婆,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情突勇,我是刑警寧澤装盯,帶...
    沈念sama閱讀 35,790評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站甲馋,受9級特大地震影響埂奈,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜定躏,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,442評論 3 331
  • 文/蒙蒙 一账磺、第九天 我趴在偏房一處隱蔽的房頂上張望芹敌。 院中可真熱鬧,春花似錦垮抗、人聲如沸氏捞。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,996評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽液茎。三九已至,卻和暖如春辞嗡,著一層夾襖步出監(jiān)牢的瞬間捆等,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,113評論 1 272
  • 我被黑心中介騙來泰國打工续室, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留栋烤,地道東北人。 一個月前我還...
    沈念sama閱讀 48,332評論 3 373
  • 正文 我出身青樓猎贴,卻偏偏與公主長得像班缎,于是被迫代替她去往敵國和親蝴光。 傳聞我的和親對象是個殘疾皇子她渴,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,044評論 2 355

推薦閱讀更多精彩內(nèi)容