0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

RaspberryPi3に64bitのubuntu-serverを入れてからsshでアクセスできるようになるまで

Last updated at Posted at 2020-12-05

インストール

公式 [https://www.raspberrypi.org/software/] のImagerにあるので入れましょう。
スクリーンショット 2020-12-05 21.06.56.png

初回ログイン

パスワード変更後にユーザーubuntuでログインできるようになります。
(有線でLANに繋がっているものとします。繋ぐだけで大丈夫です。有線LANに関する設定は特にないと思います。)

ubuntu login:ubuntu
Password:ubuntu
Current password:ubuntu
New password:<新しいパスワードを入力>
Retype new password:<新しいパスワードを再入力>

ホスト名変更

デフォルトのホスト名はubuntuです。wanwanに変更します、

ubuntu@ubuntu:~$ hostname
ubuntu
ubuntu@ubuntu:~$ hostnamectl set-hostname wanwan
ubuntu@ubuntu:~$ hostnamectl
    Static hostname: wanwan

再起動しまししょう

ubuntu@ubuntu:~$ sudo reboot

ユーザー追加

デフォルトのユーザー名はubuntuです。piというユーザーを追加します。

ubuntu@wanwan:~$ sudo adduser pi
Adding user `pi' ...
Adding new group `pi' (1002) ...
Adding new user `pi' (1002) with group `pi' ...
Creating home directory `/home/pi' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:<新しいパスワードを入力>
Retype new UNIX password:<新しいパスワードを再入力>
passwd: password updated successfully
Changing the user information for pi
Enter the new value, or press ENTER for the default
        Full Name []:
        Room Number []: 
        Work Phone []: 
        Home Phone []: 
        Other []: 
Is the information correct? [Y/n] Y

須藤さんの家族にしてあげます。家族でなければスーパーユーザー権限が必要なコマンドが実行できません。

pi@wanwan:~$ sudo gpasswd -a pi sudo
Adding user pi to group sudo

ログアウトして、新規作成したpiでログインしてみましょう。

wanwan login: pi
Password: 

pi@wanwan:~$ 

OKですね。

日本語キーボード配列に変更

英語のままだと@マークとかの場所が分からないので設定必須。
もっと先に設定してもいいですけど、この先でsshの設定しようとしたら@が入れられなかったので、ここで気が付いただけです。

pi@wanwan:~$ sudo dpkg-reconfigure keyboard-configuration

DSC_0057[1].JPG
DSC_0058[1].JPG
DSC_0059[1].JPG
DSC_0060[1].JPG
DSC_0062[1].JPG
最後OKを選ばないでenter押すとコケるぞ。注意。
キーボード配列変更を反映させるにはrebootが必要だぞ。

pi@wanwan:~$ sudo reboot

avahi-daemonのインストール

ホスト名.localで他のサーバーにアクセスする為のサービス。
「IPアドレス直打ちしかしない」っていうマゾの人とか「ローカルでもネームサーバーで管理する」っていうつよつよの人には不要。

pi@wanwan:~$ sudo apt-get install avahi-daemon

インストールだけでサービス開始されるので、設定とか特に必要なし。
適当なサーバーにpingできるか確認してみよう。

pi@wanwan:~$ ping h81s2.local

SSHで繋いでみる

pi@wanwan:~$ ssh ayumi@h81s2.local
ayumi@h81s2.local's password:
Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-56-generic x86_64)

ayumi@h81s2:~$

大丈夫みたいですね。

公開キー設定

こっちからはあまり使わないかもだけど一応ね。

pi@wanwan:~$ ssh-keygen
pi@wanwan:~$ ls .ssh
id_rsa id_rsa.pub
pi@wanwan:~$ ssh-copy-id -i .ssh/id_rsa.pub ayumi@h81s2.local
pi@wanwan:~$ ssh ayumi@h81s2.local
ayumi@h81s2:~$

接続元(クライアント側)から。こっちからのほうが使うかな。
既に持っている公開キーを送る

ayumi@h81s2:~$ ssh-copy-id -i .ssh/id_rsa.pub pi@wanwan.local

まあ、繋がるでしょう。

必要ならwifiの設定して終わり。
https://qiita.com/Roy_F/items/1637a67376ec7c855164
あとは、リモートで繋いでの作業になるので、モニタとかキーボードとか外しちゃっていいよ。

リモートでやりたい放題してください。以上。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?