Gestire da remoto SSH

  • Autore discussione Autore discussione as67
  • Data d'inizio Data d'inizio
Pubblicità

as67

Nuovo Utente
Messaggi
19
Reazioni
2
Punteggio
25
salve ho in casa due PC con Ubuntu, quello che voglio usare come client ha indirizzo 192.168.1.26 e nomeHost Alessio-Casa, l'altro che voglio usare come server ed è collegato al router direttamente dietro a AliceGate WiFi ha indirizzo 192.168.1.33 e nomeHost alessio-Ults.
Pur avendo naturalmente installato openssh server, sul pc server, cambiato la porta 22 con un'altra per sicurezza, perchè non mi fa vedere il pc server e mi dice da terminale port22 accesso negato?
ho usato:
ssh USERNAME@IP
ssh IP -l USERNAME 2443(nuova porta)
ssh IP -l USERNAME
naturalmente del server sia IP che USERNAME

dove sbaglio?
Grazie a chi puo' aiutarmi.
 
Il server ssh deve avere privilegi elevati per associarsi a quella porta( man 3 bind per maggiori info), essendo la 22 riservata.
quindi scusa l'ignoranza, cosa mi proponi di fare?

- - - Updated - - -

quindi scusa l'ignoranza, cosa mi proponi di fare?
scusate, posso sapere se mi è possibile pilotare in remoto in casa da due camere diverse, un pc(senza monitor tastiera e mouse) con Ubuntu 14.04LTS con installato openssh server, da un altro pc client con installato Ubuntu 14.04LTS,questo collegato al router AliceGate voip wifi tramite cavo ethernet e quello server collegato ad una delle porte dietro al router? Grazie mille.....
 
quindi scusa l'ignoranza, cosa mi proponi di fare?
Avvialo con sudo/root.

scusate, posso sapere se mi è possibile pilotare in remoto in casa da due camere diverse, un pc(senza monitor tastiera e mouse) con Ubuntu 14.04LTS con installato openssh server, da un altro pc client con installato Ubuntu 14.04LTS,questo collegato al router AliceGate voip wifi tramite cavo ethernet e quello server collegato ad una delle porte dietro al router? Grazie mille.....
Pilotare? Specifica cosa intendi. Detto così mi pare che il server sia un velivolo aereo...
 
Avvialo con sudo/root.


Pilotare? Specifica cosa intendi. Detto così mi pare che il server sia un velivolo aereo...
Guarda per favore....hai capito cosa intendo...desidero sapere se c'è oppure no una soluzione, grazie.

- - - Updated - - -

Siccome sono ignorante a riguardo, potete dirmi esattamente cosa scrivere su terminale per favore?
 
Se fai un telnet verso la porta 2443 del server la vedi aperta? Se non la vedi aperta non c'è modo di accedervi finchè non la apri.
Non so quanto sia uno scrupolo sensato cambiare la porta di un server SSH, sono 8 anni che lavoro su server mission critical per molte aziende importanti e non ho mai visto nessuno che cambiasse porta. La prima S di SSH sta per "Secure"...
 
Se fai un telnet verso la porta 2443 del server la vedi aperta? Se non la vedi aperta non c'è modo di accedervi finchè non la apri.
Non so quanto sia uno scrupolo sensato cambiare la porta di un server SSH, sono 8 anni che lavoro su server mission critical per molte aziende importanti e non ho mai visto nessuno che cambiasse porta. La prima S di SSH sta per "Secure"...

Yes, detta in altro modo: la security through obscurity non paga. Cambiare porta va bene al massimo per allontanare gli script kiddies meno smaliziati.

@as67: per capirci qualcosa, io direi di dare un comando del genere, a parte "telnet" suggerito da Ico.

Codice:
ssh -vvv USERNAME@IP:2443

Le tre "v" servono per attivare la modalità verbose, che mostra i messaggi di debug. Incolla sul forum nei tag CODE l'output che ricevi.
 
alessio@Alessio-Casa:~$ ssh -vvv alessio-Ults@192.168.1.33:2443
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
ssh: Could not resolve hostname 192.168.1.33:2443: Name or service not known
questo è l'output da client, va bene ugualmente?

- - - Updated - - -

Se fai un telnet verso la porta 2443 del server la vedi aperta?
cosa vuol dire e come si fa?

ok trovato

alessio@Alessio-Casa:~$ telnet 192.168.1.33 2443
Trying 192.168.1.33...
Connected to 192.168.1.33.
Escape character is '^]'.
SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2

- - - Updated - - -

ho detto che sono ignorante a riguardo, quindi chiedo solo gentilmente se è possibile gestire il pc che è un un'altra stanza senza monitor, tastiera e mouse...tutto quà!
la porta l'ho modificata solo perchè ho letto che era meglio modificarla, solo per questo l'ho cambiata, poi che sia la22 la 222, la 2222...ecc, non essendo un tecnico specializzato in reti, per me è la stessa cosa. Grazie.

se devo disinstallare e reinstallare openssh server dal pc, lasciando la porta 22 ditemelo che poi lo faccio

- - - Updated - - -

alessio@Alessio-Casa:~$ ping 192.168.1.33
PING 192.168.1.33 (192.168.1.33) 56(84) bytes of data.
64 bytes from 192.168.1.33: icmp_seq=1 ttl=64 time=0.472 ms
64 bytes from 192.168.1.33: icmp_seq=2 ttl=64 time=0.275 ms
64 bytes from 192.168.1.33: icmp_seq=3 ttl=64 time=0.262 ms
64 bytes from 192.168.1.33: icmp_seq=4 ttl=64 time=0.256 ms
64 bytes from 192.168.1.33: icmp_seq=5 ttl=64 time=0.258 ms
64 bytes from 192.168.1.33: icmp_seq=6 ttl=64 time=0.251 ms
64 bytes from 192.168.1.33: icmp_seq=7 ttl=64 time=0.254 ms
64 bytes from 192.168.1.33: icmp_seq=8 ttl=64 time=0.283 ms
64 bytes from 192.168.1.33: icmp_seq=9 ttl=64 time=0.278 ms
64 bytes from 192.168.1.33: icmp_seq=10 ttl=64 time=0.244 ms
64 bytes from 192.168.1.33: icmp_seq=11 ttl=64 time=0.261 ms
64 bytes from 192.168.1.33: icmp_seq=12 ttl=64 time=0.275 ms
64 bytes from 192.168.1.33: icmp_seq=13 ttl=64 time=0.254 ms
64 bytes from 192.168.1.33: icmp_seq=14 ttl=64 time=0.280 ms
64 bytes from 192.168.1.33: icmp_seq=15 ttl=64 time=0.279 ms
64 bytes from 192.168.1.33: icmp_seq=16 ttl=64 time=0.281 ms
64 bytes from 192.168.1.33: icmp_seq=17 ttl=64 time=0.254 ms
64 bytes from 192.168.1.33: icmp_seq=18 ttl=64 time=0.280 ms
64 bytes from 192.168.1.33: icmp_seq=19 ttl=64 time=0.284 ms
64 bytes from 192.168.1.33: icmp_seq=20 ttl=64 time=0.275 ms
64 bytes from 192.168.1.33: icmp_seq=21 ttl=64 time=0.275 ms
64 bytes from 192.168.1.33: icmp_seq=22 ttl=64 time=0.250 ms
 
Ultima modifica:
alessio@Alessio-Casa:~$ telnet 192.168.1.33 2443
Trying 192.168.1.33...
Connected to 192.168.1.33.
Escape character is '^]'.
SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2

- - - Updated - - -

ho detto che sono ignorante a riguardo, quindi chiedo solo gentilmente se è possibile gestire il pc che è un un'altra stanza senza monitor, tastiera e mouse...tutto quà!

La risposta è si. OpenSSH serve proprio a questo. Non so dirti precisamente perché non riesca a connettersi, ma cercando su google "ssh: could not resolve hostname" si trovano alcuni risultati, prova con il comando così modificato.

La cosa preoccupante è che telnet è aperto, senza richiedere autenticazione (infatti se noti hai eseguito il login sulla macchina remota). Non serve la sicurezza di SSH se poi telnet è aperto a tutti. Ovviamente niente ti impedisce di fregartene della sicurezza di ssh e usare direttamente telnet.
 
La cosa preoccupante è che telnet è aperto...Cosa vuol dire!!!
Comunque ho tolto e rimesso su pc server openssh server, e tolto dal router la porta che avevo cambiato su SSH.
Ora prima di togliere dal pc server tastiera mouse e monitor, e ricollegarlo nell'altra stanza al router, cosa posso fare per controllare che è tutto ok?
 
Ultima modifica:
Tranquillo, telnet era aperto su quella porta perchè c'era OpenSSH in ascolto, non è un buco di sicurezza. Ma tanto, se stai dietro ad un router/firewall, anche se avessi il telnet aperto (quello sulla porta 23 che chiede il login, con cui ci si collegava in remoto ai server prima che inventassero metodi più sicuri) non ci sarebbe da preoccuparsi più di tanto.
Per poter togliere mouse e tastiera e monitor basta che ti assicuri che funzioni (ssh -l username xxx.xxx.xxx.xxx). Ocio che se quel server è in DHCP è anche capace che se lo sposti cambi indirizzo IP
 
Tranquillo, telnet era aperto su quella porta perchè c'era OpenSSH in ascolto, non è un buco di sicurezza. Ma tanto, se stai dietro ad un router/firewall, anche se avessi il telnet aperto (quello sulla porta 23 che chiede il login, con cui ci si collegava in remoto ai server prima che inventassero metodi più sicuri) non ci sarebbe da preoccuparsi più di tanto.
Per poter togliere mouse e tastiera e monitor basta che ti assicuri che funzioni (ssh -l username xxx.xxx.xxx.xxx). Ocio che se quel server è in DHCP è anche capace che se lo sposti cambi indirizzo IP
allora, il pc non l'ho ancora staccato e messo nell'altra stanza però mi da:

alessio@alessio-Ults:~$ ssh -l alessio-Ults 192.168.1.33
ssh: connect to host 192.168.1.33 port 22: Connection refused
alessio@alessio-Ults:~$

cosa vuol dire? perchè mi da sempre port22: connection refused?

- - - Updated - - -

dunque scusate, vorrei dire una cosa a questo punto e poi rinuncio definitivamente...non è che mi dice sempre port22 connection refused perchè non faccio questa operazione direttamente dove dovrebbe essere il pc server, cioè connesso al router? oppure non cambia nulla?

- - - Updated - - -

ho disattivato anche il firewall del router dando da terminale
alessio@alessio-Ults:~$ ssh alessio-Ults@127.0.0.1
ssh: connect to host 127.0.0.1 port 22: Connection refused
alessio@alessio-Ults:~$

ma niente

col suo IP:

alessio@alessio-Ults:~$ ssh alessio-Ults@192.168.1.33
ssh: connect to host 192.168.1.33 port 22: Connection refused
alessio@alessio-Ults:~$

naturalmente lo sto facendo dal terminale del server da cui non ho ancora staccato monito, tastiera, mouse e non l'ho messo nell'altra stanza collegandolo dietro al router...giusto per essere precisi!

ma non è possibile da questa situazione capire se l'SSH lavora come deve, se tutto funziona bene?

- - - Updated - - -

comunque ho ricollegato il pc server e tolto monitor, tastiera e mouse.
 
dunque scusate, vorrei dire una cosa a questo punto e poi rinuncio definitivamente...non è che mi dice sempre port22 connection refused perchè non faccio questa operazione direttamente dove dovrebbe essere il pc server, cioè connesso al router? oppure non cambia nulla?
Questa cosa non l'ho capita.
Se non funziona ssh -l username localhost significa che il server ssh non è attivo o che è in ascolto su una porta diversa dalla 22, non ci sono gatti.
Sicuro che i processi siano attivi? Che ti esce se dai ps -ef | grep ssh? Non è che magari il server è ancora in ascolto sulla porta che avevi settato prima?
 
Dal server dai
Codice:
ss -t -l -p -n | grep ssh
per individuare su quale porta sta ascoltando il server. Se non puoi, fai un port scan con nmap di tutte le porte da un client nella lan.
 
Ultima modifica:
Dal server dai
Codice:
ss -t -l -p -n | grep ssh
per individuare su quale porta sta ascoltando il server. Se non puoi, fai un port scan con nmap di tutte le porte da un client nella lan.
cioè dal terminale del client cosa devo dare?

- - - Updated - - -

ok la risposta è:
Nmap 6.40 ( Nmap - Free Security Scanner For Network Exploration & Security Audits. )
Usage: nmap [Scan Type(s)] [Options] {target specification}
TARGET SPECIFICATION:
Can pass hostnames, IP addresses, networks, etc.
Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254
-iL <inputfilename>: Input from list of hosts/networks
-iR <num hosts>: Choose random targets
--exclude <host1[,host2][,host3],...>: Exclude hosts/networks
--excludefile <exclude_file>: Exclude list from file
HOST DISCOVERY:
-sL: List Scan - simply list targets to scan
-sn: Ping Scan - disable port scan
-Pn: Treat all hosts as online -- skip host discovery
-PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports
-PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes
-PO[protocol list]: IP Protocol Ping
-n/-R: Never do DNS resolution/Always resolve [default: sometimes]
--dns-servers <serv1[,serv2],...>: Specify custom DNS servers
--system-dns: Use OS's DNS resolver
--traceroute: Trace hop path to each host
SCAN TECHNIQUES:
-sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans
-sU: UDP Scan
-sN/sF/sX: TCP Null, FIN, and Xmas scans
--scanflags <flags>: Customize TCP scan flags
-sI <zombie host[:probeport]>: Idle scan
-sY/sZ: SCTP INIT/COOKIE-ECHO scans
-sO: IP protocol scan
-b <FTP relay host>: FTP bounce scan
PORT SPECIFICATION AND SCAN ORDER:
-p <port ranges>: Only scan specified ports
Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080,S:9
-F: Fast mode - Scan fewer ports than the default scan
-r: Scan ports consecutively - don't randomize
--top-ports <number>: Scan <number> most common ports
--port-ratio <ratio>: Scan ports more common than <ratio>
SERVICE/VERSION DETECTION:
-sV: Probe open ports to determine service/version info
--version-intensity <level>: Set from 0 (light) to 9 (try all probes)
--version-light: Limit to most likely probes (intensity 2)
--version-all: Try every single probe (intensity 9)
--version-trace: Show detailed version scan activity (for debugging)
SCRIPT SCAN:
-sC: equivalent to --script=default
--script=<Lua scripts>: <Lua scripts> is a comma separated list of
directories, script-files or script-categories
--script-args=<n1=v1,[n2=v2,...]>: provide arguments to scripts
--script-args-file=filename: provide NSE script args in a file
--script-trace: Show all data sent and received
--script-updatedb: Update the script database.
--script-help=<Lua scripts>: Show help about scripts.
<Lua scripts> is a comma separted list of script-files or
script-categories.
OS DETECTION:
-O: Enable OS detection
--osscan-limit: Limit OS detection to promising targets
--osscan-guess: Guess OS more aggressively
TIMING AND PERFORMANCE:
Options which take <time> are in seconds, or append 'ms' (milliseconds),
's' (seconds), 'm' (minutes), or 'h' (hours) to the value (e.g. 30m).
-T<0-5>: Set timing template (higher is faster)
--min-hostgroup/max-hostgroup <size>: Parallel host scan group sizes
--min-parallelism/max-parallelism <numprobes>: Probe parallelization
--min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <time>: Specifies
probe round trip time.
--max-retries <tries>: Caps number of port scan probe retransmissions.
--host-timeout <time>: Give up on target after this long
--scan-delay/--max-scan-delay <time>: Adjust delay between probes
--min-rate <number>: Send packets no slower than <number> per second
--max-rate <number>: Send packets no faster than <number> per second
FIREWALL/IDS EVASION AND SPOOFING:
-f; --mtu <val>: fragment packets (optionally w/given MTU)
-D <decoy1,decoy2[,ME],...>: Cloak a scan with decoys
-S <IP_Address>: Spoof source address
-e <iface>: Use specified interface
-g/--source-port <portnum>: Use given port number
--data-length <num>: Append random data to sent packets
--ip-options <options>: Send packets with specified ip options
--ttl <val>: Set IP time-to-live field
--spoof-mac <mac address/prefix/vendor name>: Spoof your MAC address
--badsum: Send packets with a bogus TCP/UDP/SCTP checksum
OUTPUT:
-oN/-oX/-oS/-oG <file>: Output scan in normal, XML, s|<rIpt kIddi3,
and Grepable format, respectively, to the given filename.
-oA <basename>: Output in the three major formats at once
-v: Increase verbosity level (use -vv or more for greater effect)
-d: Increase debugging level (use -dd or more for greater effect)
--reason: Display the reason a port is in a particular state
--open: Only show open (or possibly open) ports
--packet-trace: Show all packets sent and received
--iflist: Print host interfaces and routes (for debugging)
--log-errors: Log errors/warnings to the normal-format output file
--append-output: Append to rather than clobber specified output files
--resume <filename>: Resume an aborted scan
--stylesheet <path/URL>: XSL stylesheet to transform XML output to HTML
--webxml: Reference stylesheet from Nmap.Org for more portable XML
--no-stylesheet: Prevent associating of XSL stylesheet w/XML output
MISC:
-6: Enable IPv6 scanning
-A: Enable OS detection, version detection, script scanning, and traceroute
--datadir <dirname>: Specify custom Nmap data file location
--send-eth/--send-ip: Send using raw ethernet frames or IP packets
--privileged: Assume that the user is fully privileged
--unprivileged: Assume the user lacks raw socket privileges
-V: Print version number
-h: Print this help summary page.
EXAMPLES:
nmap -v -A scanme.nmap.org
nmap -v -sn 192.168.0.0/16 10.0.0.0/8
nmap -v -iR 10000 -Pn -p 80
SEE THE MAN PAGE (ChapterÂ*15.Â*Nmap Reference Guide) FOR MORE OPTIONS AND EXAMPLES
alessio@Alessio-Casa:~$

quindi?

- - - Updated - - -
fai un port scan con nmap di tutte le porte da un client nella lan.
devo dare il comando nmap e l' IP della macchina server dal terminale della macchina client?

- - - Updated - - -

Questa cosa non l'ho capita.
Se non funziona ssh -l username localhost significa che il server ssh non è attivo o che è in ascolto su una porta diversa dalla 22, non ci sono gatti.
Sicuro che i processi siano attivi? Che ti esce se dai ps -ef | grep ssh? Non è che magari il server è ancora in ascolto sulla porta che avevi settato prima?
dunque reinstallato openssh server sul pc
[QUOTE alessio@alessio-Ults:~$ sudo apt-get install openssh-server
[sudo] password for alessio:
Lettura elenco dei pacchetti... Fatto
Generazione albero delle dipendenze
Lettura informazioni sullo stato... Fatto
I seguenti pacchetti saranno inoltre installati:
openssh-sftp-server python-requests ssh-import-id
Pacchetti suggeriti:
rssh
I seguenti pacchetti NUOVI saranno installati:
openssh-server openssh-sftp-server python-requests ssh-import-id
0 aggiornati, 4 installati, 0 da rimuovere e 1 non aggiornati.
È necessario scaricare 0 B/411 kB di archivi.
Dopo quest'operazione, verranno occupati 1.432 kB di spazio su disco.
Continuare? [S/n] s
E: Si è verificato un problema nel rinominare il file /var/cache/apt/pkgcache.bin.QjC7Bv in /var/cache/apt/pkgcache.bin - rename (2: File o directory non esistente)
debconf: apt-extracttemplates fallito: File o directory non esistente
Selezionato il pacchetto openssh-sftp-server non precedentemente selezionato.
(Lettura del database... 250467 file e directory attualmente installati.)
Preparativi per estrarre .../openssh-sftp-server_1%3a6.6p1-2ubuntu2_i386.deb...
Estrazione di openssh-sftp-server (1:6.6p1-2ubuntu2)...
Selezionato il pacchetto openssh-server non precedentemente selezionato.
Preparativi per estrarre .../openssh-server_1%3a6.6p1-2ubuntu2_i386.deb...
Estrazione di openssh-server (1:6.6p1-2ubuntu2)...
Selezionato il pacchetto python-requests non precedentemente selezionato.
Preparativi per estrarre .../python-requests_2.2.1-1_all.deb...
Estrazione di python-requests (2.2.1-1)...
Selezionato il pacchetto ssh-import-id non precedentemente selezionato.
Preparativi per estrarre .../ssh-import-id_3.21-0ubuntu1_all.deb...
Estrazione di ssh-import-id (3.21-0ubuntu1)...
Elaborazione dei trigger per man-db (2.6.7.1-1)...
Elaborazione dei trigger per ureadahead (0.100.0-16)...
ureadahead will be reprofiled on next reboot
Elaborazione dei trigger per ufw (0.34~rc-0ubuntu2)...
Configurazione di openssh-sftp-server (1:6.6p1-2ubuntu2)...
Configurazione di openssh-server (1:6.6p1-2ubuntu2)...
ssh start/running, process 4470
Configurazione di python-requests (2.2.1-1)...
Configurazione di ssh-import-id (3.21-0ubuntu1)...
alessio@alessio-Ults:~$
][/QUOTE]
ho aperto la porta 22 su Port Mapping del router associato all'IP della macchina server
ma mi da sempre la stessa risposta:
alessio@Alessio-Casa:~$ ssh alessio@192.168.1.33
ssh: connect to host 192.168.1.33 port 22: Connection refused
alessio@Alessio-Casa:~$

Sicuro che i processi siano attivi? Che ti esce se dai ps -ef | grep ssh? Non è che magari il server è ancora in ascolto sulla porta che avevi settato prima?

lo devo fare dalla macchina server o posso farlo da quella client?
 
Ultima modifica:
Pubblicità
Pubblicità
Indietro
Top