ssh远程登陆virtualbox debian12

1. 检查ssh是否安装

ps -e | grep ssh

image

只有ssh-agent表示没装

1.1 安装ssh-server

sudo apt install openssh-server -y

image

2. Virtualbox网络设置

image

3. ssh远程登陆

# 获取ip
$ hostname -I

# 远程登陆
$ ssh blue@172.16.237.188

image

4. ssh免密登陆

# 复制公钥
cat id_rsa.pub | ssh blue@172.16.237.188 'cat >> .ssh/authorized_keys'

# 添加host别名
$ vi ~/.ssh/config
Host d12
HostName 172.16.237.188
User blue
IdentityFile ~/.ssh/id_rsa

# 免密登陆
$ ssh d12

image

其它问题

blue is not in the sudoers file

$ su root
$ vi /etc/sudoers
blue ALL=(ALL:ALL) ALL

image

设置更新源

$ vi /etc/apt/sources.list

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware

# deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware

参考

https://mirrors.tuna.tsinghua.edu.cn/help/debian/

posted @ 2023-07-16 15:51  BuzzWeek  阅读(364)  评论(0编辑  收藏  举报