Arquivo da tag: Ubuntu

Erro “Connection refused” em conexão ssh

O ssh tava apresentando o erro abaixo:

ssh: connect to host 192.168.XXX.XXX port 22: Connection refused

 

até o passo 3, resolveu meu problema
  1. First check openssh-server installed in that system.
  2. check the status of ssh service, make ssh service start.
    sudo service ssh status    
    sudo service ssh start
    
  3. Check iptables in that system that port 22 is blocked. Just allow port in iptables and then check.
    sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT
    
  4. Else change port number of ssh from 22 to 2222 by editing
    vi /etc/ssh/sshd_config    
    /etc/init.d/ssh restart.
    

pra mim, resolveu o problema em um ubuntu server 18.04.2

Anúncios

alterar o hostname do ubuntu

dica retirada do site: https://linuxize.com/post/how-to-change-hostname-on-ubuntu-18-04/

This tutorial will guide you through the process of changing the hostname on an Ubuntu 18.04 system.

The hostname is set at the time when the Ubuntu operating system is installed or if you are spinning up a virtual machine it is dynamically assigned to the instance at startup.

The method described in this guide will work without the need of restarting your system.

Although this tutorial is written for Ubuntu 18.04 the same instructions apply for Ubuntu 16.04 and any Ubuntu-based distribution, including Linux Mint and Elementary OS.

Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges.

A hostname is a label that identifies a machine on the network. You shouldn’t use the same hostname on two different machines on a same network.

To view the current hostname, enter the following command:

hostnamectl

Copy

As you can see in the image above, the current hostname is set to ubuntu1804.localdomain.

The following steps outline how to change the hostname in Ubuntu 18.04.

In Ubuntu 18.04 we can change the system hostname and related settings using the command hostnamectl.

For example, to change the system static hostname to linuxize, you would use the following command:

sudo hostnamectl set-hostname linuxize

Copy

The hostnamectl command does not produce output. On success, 0 is returned, a non-zero failure code otherwise.

Open the /etc/hosts file and change the old hostname to the new one.

/etc/hosts
127.0.0.1   localhost
127.0.0.1   linuxize

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Copy

If the cloud-init package is installed you also need to edit the cloud.cfg file. This package is usually installed by default in the images provided by the cloud providers such as AWS and it is used to handle the initialization of the cloud instances.

To check if the package is installed run the following ls command:

ls -l /etc/cloud/cloud.cfg

Copy

If you see the following output it means that the package is not installed and no further action is required.

ls: cannot access '/etc/cloud/cloud.cfg': No such file or directory

Copy

If the package is installed the output will look like the following:

-rw-r--r-- 1 root root 3169 Apr 27 09:30 /etc/cloud/cloud.cfg

Copy

In this case you’ll need to open the /etc/cloud/cloud.cfg file:

sudo nano /etc/cloud/cloud.cfg

Copy

Search for preserve_hostname and change the value from false to true:

/etc/cloud/cloud.cfg
# This will cause the set+update hostname module to not operate (if true)
preserve_hostname: true

Copy

Save the file and close your editor.

To verify that the hostname was successfully changed, once again use the hostnamectlcommand:

hostnamectl

Copy

   Static hostname: linuxize
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 6f17445f53074505a008c9abd8ed64a5
           Boot ID: 1c769ab73b924a188c5caeaf8c72e0f4
    Virtualization: kvm
  Operating System: Ubuntu 18.04 LTS
            Kernel: Linux 4.15.0-22-generic
      Architecture: x86-64

Copy

You should see your new server name printed on the console.

In this tutorial, we have shown you how to easily change your Ubuntu server hostname without restarting the machine.

Instalando VirtualBox 6.0 no Ubuntu 18.04

testei em um ubuntu 18.04.2

PASSO 1 – instalando virtualbox 6.0

fonte: https://tecadmin.net/install-virtualbox-on-ubuntu-18-04/

Step 1 – Prerequsities

Login to your Ubuntu 18.04 desktop system with sudo privileged user. After login to your system update current packages of the system to the latest version.

sudo apt update
sudo apt upgrade

Step 2 – Setup Apt Repository

Now, import the Oracle public key to your system signed the Debian packages using the following commands.

wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -

Then, you need to add Oracle VirtualBox PPA to Ubuntu system. You can do this by running the below command on your system.

sudo add-apt-repository "deb http://download.virtualbox.org/virtualbox/debian bionic contrib"

This command will add an entry to /etc/apt/sources.list at end of the file.

Step 3 – Install VirtualBox on Ubuntu 18.04

After completing the above steps, let’s install VirtualBox using the following commands. If you have already installed an older version of VirtualBox, Below command will update it automatically.

sudo apt update
sudo apt install virtualbox-6.0

Step 4 – Launch VirtualBox

We can use dashboard shortcuts to start VirtualBox or simply run following command from a terminal.

virtualbox

Install Virtualbox on Ubuntu 18.04

fonte: https://tecadmin.net/install-virtualbox-on-ubuntu-18-04/

configurar x11vnc no ubuntu

testei em um ubuntu 18.04.2 server com lxde

  1. instalar o x11vnc
    1. sudo apt-get install x11vnc -y
  2. configurar a senha do vnc
    1. x11vnc -storepasswd
  3. configurar a inicialização automática no boot:
    1. sudo nano /etc/systemd/system/x11vnc.service
    2. adicione o texto:
      1. [Unit]
        Description=x11vnc remote desktop server
        After=multi-user.target

        [Service]
        Type=simple
        ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/SEUUSUARIO/.vnc/passwd -rfbport 5900 -shared -o /var/log/x11vnc.log

        Restart=on-failure

        [Install]
        WantedBy=multi-user.target

    3. dar permissões:
      1. sudo chmod 777 /etc/systemd/system/x11vnc.service
    4. adicionar os daemons:
      1. sudo systemctl daemon-reload
      2. sudo systemctl start x11vnc
      3. sudo systemctl status x11vnc
    5. ativar o serviço:
      1. sudo systemctl enable x11vnc.service
    6. reinicie o pc para conferir o funcionamento:
      1. sudo reboot

caso necessite ver o log em caso de erro: /var/log/x11vnc.log

fontes:
https://tecadmin.net/setup-x11vnc-server-on-ubuntu-linuxmint/
https://theseekersquill.wordpress.com/2010/03/16/vnc-server-ubuntu-windows/
https://askubuntu.com/questions/87401/how-can-i-enable-remote-control-desktop-sharing-on-lubuntu
https://www.raspberrypi.org/forums/viewtopic.php?t=50859

UPDATE:

eu estava tendo problemas de tela preta após realizar o acesso via vnc e bloquear a área de trabalho. Isso é causado por um “desentendimento” entre o light-locker e o x11vnc!
Primeiro como tentativa de resolver tive que parar o x11vnc, matar o ightdm, e reiniciar o x11vnc.
sudo systemctl stop x11vnc.service
sudo killall -9 lightdm
sudo systemctl start x11vnc.service
mas fazendo isso matava todos processos que estavam rodando na sessão havia ficado bloqueada, era a mesma coisa que fazer um logoff. Não era a melhor solução.
Pesquisando, achei algo que resolvia de forma funcional, basta desinstalar o light-locker
sudo apt-get remove light-locker
com isso, não terá mais as proteção de tela, e o bloqueio será assumido pelo XScreenSaver
Obs.: não faça troca de usuário, ou a tela ficará preta novamente. Infelizmente a solução ainda é incompleta 😦

 

Debian e ubuntu – desabilitar suspensão e hibernação via systemd

fonte: https://elias.praciano.com/2016/09/desabilite-as-opcoes-de-suspensao-e-hibernacao-no-debian/

esta dica me ajudou e também funcionou no ubuntu 18.04

 

como desabilitar suspensão e hibernação via systemd

Se você quiser impedir que seu sistema tente hibernar, use o systemd para desabilitar a função.
A seguinte linha de comando, deve resolver o assunto:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

Se quiser desfazer o procedimento, realize o seguinte comando:

sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target

Para desabilitar a suspensão quando a tampa do notebook for fechada, ajuste os seguintes parâmetros no arquivo de configuração /etc/systemd/logind.conf:

[Login]
HandleLidSwitch=ignore
HandleLidSwitchDocked=ignore

Obs.: no meu caso eu também adicionei as linhas:
HandlePowerKey=ignore
HandleSuspendKey=ignore
HandleHibernateKey=ignore

Em seguida rode o comando systemctl, da seguinte forma:

systemctl restart systemd-logind.service

ou reinicie a máquina.

Referências

https://wiki.debian.org/Suspend

ubuntu – linha de comando para configurar teclado brasileiro

fonte: https://www.vivaolinux.com.br/dica/Layout-de-teclado-para-ABNT2-Configuracao-no-Ubuntu-modo-texto

LAYOUT DE TECLADO PARA ABNT2 – CONFIGURAÇÃO NO UBUNTU (MODO TEXTO)

1. No terminal, digite como root:

# vi /etc/default/keyboard  # Troque pelo editor de sua preferência

2. Procure a seguinte linha:

XKBLAYOUT

3. Altere para br, se o teclado for ABNT2:

XKBLAYOUT=”br”  # Layout do teclado (tipo ABNT2=br ou americano=us)

4. Salve a alteração e reinicie.

configurar ip manualmente no ubuntu server 18.04

fonte: https://askubuntu.com/questions/1036060/no-ethernet-connection-on-ubuntu-server-18-04-on-dell-power-edge-t300

 

essa dica me ajudou:

 

So, in my case, I would use the interface designation enp0s25.

Next, edit your netplan file:

sudo nano /etc/netplan/01-netcfg.yaml 

Amend the file to read:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s25:
        dhcp4: no
            addresses: [192.168.100.40/22]
            gateway4: 192.168.100.1
            nameservers:
            addresses: [8.8.8.8,8.8.4.4]

Of course, susbstitue your exact details here. Spacing, indentation, etc. are crucial. Proofread carefully. Save (Ctrl+o followed by Enter) and close (Ctrl+x) the text editor.

Next:

sudo netplan apply
sudo ip link set enp0s25 down
sudo ip link set enp0s25 up

Did you get the requested IP address?

ip addr show

Can you ping?

ping -c3 8.8.8.8
ping -c3 www.ubuntu.com

If you get ping returns, you are all set.