fleeting/fb
本机启用ssh免密自动登陆modified | Sunday 29 June 2025 |
---|
aliases:
1ssh-copy-id -i ~/.ssh/id_rsa.pub username@192.168.2.22
成功后则会提示:
1/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/Users/username/.ssh/id_rsa.pub"
2/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
3/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
4username@192.168.2.22's password:
5
6Number of key(s) added: 1
7
8Now try logging into the machine, with: "ssh 'username@192.168.2.22'"
9and check to make sure that only the key(s) you wanted were added.
1ssh username@192.168.2.22
如果本地之前已经配置好[[ssh config 文件]],则这边好像不用配了,vscode也能直接连上ssh
Remote-SSH
插件, 点击 vscode 左下角绿色箭头打开远程连接, 选择 open configuration file
, 输入: 1Host 2.22_username
2 HostName 192.168.2.22
3 User username
4 PreferredAuthentications publickey
5 IdentityFile "/Users/username/.ssh/id_rsa"
6
7Host 2.22_username2
8 HostName 192.168.2.22
9 User username2
10 PreferredAuthentications publickey
11 IdentityFile "/Users/username/.ssh/id_rsa"
保存后, 再次用 vscode 登录即可