SSH 配置:覆盖默认用户名 [英] SSH configuration: override the default username

查看:32
本文介绍了SSH 配置:覆盖默认用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以配置 ssh 以知道我的用户名应该是什么?

Is it possible to configure ssh to know what my username should be?

默认情况下它使用当前用户名,这对我来说是不正确的.

By default it uses the current username, which is not correct in my case.

我在借用笔记本电脑,我的用户名是 loaner,但我想告诉 ssh 我的用户名是 buck.

I'm on a loaner laptop, and my username is loaner, but I want to tell ssh that my username is buck.

奖励积分:我在家里的用户名是 bgolemon.如果我可以为每个主机配置用户名,那就更好了.

Bonus points: my username at home is bgolemon. If I could configure the username per-host that would be even better.

推荐答案

~/.ssh 中创建一个名为 config 的文件.您可以在文件中添加:

Create a file called config inside ~/.ssh. Inside the file you can add:

Host *
    User buck

或添加

Host example
    HostName example.net
    User buck

第二个示例将设置用户名并且特定于主机名,而第一个示例仅设置用户名.当你使用第二个时,你不需要使用 ssh example.net;ssh 示例 就足够了.

The second example will set a username and is hostname specific, while the first example sets a username only. And when you use the second one you don't need to use ssh example.net; ssh example will be enough.

这篇关于SSH 配置:覆盖默认用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆