我试图使用 ssh 实例,但收到以下错误,这很奇怪,因为我尝试使用 更改权限chmod,但这似乎不起作用,因为权限仍然存在777:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for 'privkey.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "privkey.pem": bad permissions
Permission denied (publickey).
Run Code Online (Sandbox Code Playgroud)
我打开git bash并能够毫无问题地通过 SSH 连接到我的实例,并且权限也不777是很好。
我可以创建多个 ssh 密钥,并将它们重命名为用户友好的名称,以便我知道哪个密钥用于哪个网站等。
这安全吗?
例如:
github_id_rsa
github_id_rsa.pub
..
...
Run Code Online (Sandbox Code Playgroud)
它如何知道连接时要检查哪个键?
现在在我的电脑上,当我查看 known_hosts 时,它们似乎在主机名后都有相同的键??
我在本地机器上使用 tmux,通常同时有多个会话。
我通常做的是我有一个不同窗口的会话在本地工作,而在其他会话中我将多个窗口连接到每个会话的一个主机。
在我使用 tmux 的日常使用中,会话/窗口树看起来像这样:
(TMUX on my local machine)
|
+- session 1: local
| \_ window 1: local shell
| \_ window 2: local shell
| \_ ...
|
+ session 2: somehost
| \_ window1: ssh user@somehost
| \_ window2: ssh user@somehost
| \_ ...
|
+ session 3: someotherhost
\_ window1: ssh user@someotherhost
\_ window2: ssh user@someotherhost
\_ ...
Run Code Online (Sandbox Code Playgroud)
有没有办法让会话 2 和会话 3 某种远程会话连接到在某个主机和某个主机上创建的 tmux 会话?
上面的树看起来像这样:
(TMUX on my local machine)
|
+- session …Run Code Online (Sandbox Code Playgroud) 我有一个交互式 shell 脚本,在一个地方需要 ssh 到另一台机器(基于 Ubuntu)并以 root 身份执行一些东西(用户应该输入他的密码,但远程命令应该像脚本中提到的那样运行):
# ...
ssh remote-machine 'sudo ls'
# ...
Run Code Online (Sandbox Code Playgroud)
但是,我总是收到此错误消息:
sudo: no tty present and no askpass program specified
Run Code Online (Sandbox Code Playgroud)
好的,这很清楚。但是我怎样才能规避这一点呢?应该发生这样的事情:
$ ssh remote-machine 'sudo ls /'
[sudo] password for user1:
/bin
/etc
/var
Run Code Online (Sandbox Code Playgroud) 我有一台必须通过 ssh 频繁访问的服务器,因为我在它上面进行计算。现在,计算中心明确禁止SSH 密钥,因为它们“不安全”。他们认为每次在键盘上输入我的密码,可能在其他人面前,是一种更安全的登录方式。
现在; 我无法改变他们的想法(我试过了)。
有没有办法至少临时存储 SSH 密码,就像 GIT 可以在某个定义的时间内将密码存储在缓存中的方式?
id_rsa 通常是默认键。
我创建了一个名为“keyhello”的新密钥
更新:我还通过执行以下操作添加了此密钥:
ssh-add /home/myuser/.ssh/keyhello
Run Code Online (Sandbox Code Playgroud)
但我相信它仍然不是我的默认密钥。
那么,我们如何将 keyhello 设为默认身份,而不是 id_rsa 呢?
我确实看到了 -t 但我试过:
ssh-agent /home/mysuser/.ssh/keyhello -t
Run Code Online (Sandbox Code Playgroud)
没有运气。我得到一个“权限被拒绝”(如果我把 sudo ssh-agent ......我得到了同样的“权限被拒绝,甚至提示我我的 sudo 通行证”)。
这与其说是技术问题,不如说是概念性问题。我知道 SSH 密钥中使用的密码学比普通密码强得多,但我不明白为什么它被认为更安全。
我读过的大多数教程都建议使用 SSH 密钥身份验证而不是密码身份验证。但我的理解是,任何有权访问预先批准的客户端计算机的人都将能够连接到服务器,这意味着 SSH 密钥提供的安全级别仅与物理安全级别一样强客户端机器。
例如,如果我在我的手机上设置了一个 SSH 密钥来连接到我的家用机器,如果我丢失了我的手机并且有人设法解锁它,他们将能够连接到我的家用机器。我知道然后我可以从我的家用机器上取下我手机的钥匙,但是我很容易受到攻击,直到我意识到客户端设备已经丢失/被破坏。
我是否误解了什么,或者这些是有效的担忧?
如果我执行远程端口转发,-R 3690:localhost:3690当远程主机上的端口上已经存在绑定时,我会收到以下警告:
Warning: remote port forwarding failed for listen port 3690
Run Code Online (Sandbox Code Playgroud)
有没有办法让 ssh 失败(即以非零返回码退出),而不仅仅是发出警告?
我已经设置了两个 GitHub 帐户,但我无法让 ssh 密钥正常工作。我尝试了各种配置。
Host github_username1
HostName github.com
IdentityFile ~/.ssh/rsa_1
User username1
Host github_username2
HostName github.com
IdentityFile ~/.ssh/rsa_2
User username2
Run Code Online (Sandbox Code Playgroud)
git push:
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)
适用于 username1:
Host github.com
HostName github.com
IdentityFile ~/.ssh/rsa_1
User username1
Host github.com
HostName github.com
IdentityFile ~/.ssh/rsa_2
User username2
Run Code Online (Sandbox Code Playgroud)
git push 在 username2 的仓库中:
ERROR: Permission to username2/repo.git denied to username1.
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)
我也试着git push既IdentityFile和User设置下相同Host …
当我通过 ssh 进入无头 Linux Mint 17 系统时,它不会创建更新/创建 .Xauthority 文件。
此外,当我运行时,xauth我得到了答复:
marty@N40L ~ $ xauth
xauth: file /home/marty/.Xauthority does not exist
Using authority file /home/marty/.Xauthority
xauth>exit
marty@N40L ~ $ xauth
xauth: file /home/marty/.Xauthority does not exist
Using authority file /home/marty/.Xauthority
xauth>
Run Code Online (Sandbox Code Playgroud)
它不会创建文件。
编辑:
当我连接监视器,然后在本地登录时,会创建该文件,但是当我尝试添加一个条目时(因为我的 SSH 不适合我):
marty@N40L ~ $ xauth list
N40L/unix:0 MIT-MAGIC-COOKIE-1 34eee3b15cdb281021502d40dfba1cf2
localhost.localdomain/unix:0 MIT-MAGIC-COOKIE-1 34eee3b15cdb281021502d40dfba1cf2
marty@N40L ~ $ ls -d .X*
-rw------- 1 marty marty 115 Sep 3 12:03 .Xauthority
marty@N40L ~ $ xauth generate $DISPLAY . …Run Code Online (Sandbox Code Playgroud)