[英]SSH connection refused on azure vm
我能夠在Chrome上渲染虛擬機的公共IP,但無法將其與SSH連接,從而引發錯誤:連接到主機xxx.xxx.xxx.xx端口22:連接被拒絕。 當我在Portal上檢查虛擬機時,沒有分配安全組。 這與這有關嗎? 我該如何解決?
根據您的描述,如果我們要ssh到docker鏡像,我們應該在該鏡像上安裝SSH,並打開該鏡像的端口,我將運行centos鏡像,例如:
docker pull centos:centos6
docker run -i -t centos:centos6
yum install openssh-server openssh-client(install ssh)
chkconfig sshd on
passwd(reset root password)
exit
docker commit 332b19ca916c centos/centosssh (commit this image)
docker run -i -t -d -p 50001:22 centos/centosssh (NAT for this container)
docker attach containerid (connect this container)
vi /etc/ssh/sshd_config (modify sshd config)
change UsePAM to no
service sshd start
然后在Azure NSG中打開端口50001。
這次,我們可以使用SSH連接它:
更新:
我使用CLI 2.0創建具有docker擴展名的VM,並將公共IP地址更改為static ,並使用命令sudo docker run -d -p 80:80 nginx
在VM上運行容器。 然后使用chrome測試nginx,它可以正常工作,並且我可以使用Public IP和FQDN SSH到Azure VM。 Nginx容器:
jason@MyDockerVM:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
61e10ebb6d22 nginx "nginx -g 'daemon ..." 4 minutes ago Up 4 minutes 0.0.0.0:80->80/tcp, 443/tcp kind_leavitt
嘗試使用FQDN來SSH主機:
[c:\~]$ ssh jason@mypublicdns.eastus.cloudapp.azure.com
Host 'mypublicdns.eastus.cloudapp.azure.com' resolved to 52.186.123.151.
Connecting to 52.186.123.151:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.19.0-65-generic x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Fri Apr 7 06:40:06 UTC 2017
System load: 0.31 Processes: 118
Usage of /: 5.8% of 28.80GB Users logged in: 1
Memory usage: 12% IP address for eth0: 10.0.0.4
Swap usage: 0% IP address for docker0: 172.17.0.1
嘗試使用公共IP地址來SSH主機:
[c:\~]$ ssh jason@52.186.123.151
Connecting to 52.186.123.151:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.19.0-65-generic x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Fri Apr 7 06:40:55 UTC 2017
System load: 0.21 Processes: 119
Usage of /: 5.8% of 28.80GB Users logged in: 1
Memory usage: 12% IP address for eth0: 10.0.0.4
Swap usage: 0% IP address for docker0: 172.17.0.1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.