LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-21-2012, 05:34 AM   #1
Arjun
Member
 
Registered: Feb 2011
Posts: 120
Blog Entries: 2

Rep: Reputation: 0
ssh Connection


I am new to this.

I want to make connection to localhost via ssh. I have read some tutorials but they were for remote machine & so doesnt working on localhost.

So i want to know that how can i connect to localhost via SSH.

Thanks
 
Old 07-21-2012, 05:37 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
If you have the SSH daemon running, you can just do "ssh localhost" or "ssh 127.0.0.1". Why do you want to do this, though?
 
Old 07-21-2012, 05:47 AM   #3
Arjun
Member
 
Registered: Feb 2011
Posts: 120

Original Poster
Blog Entries: 2

Rep: Reputation: 0
I have tried this but the output i got is

Quote:
ssh: connect to host localhost port 22: Connection refused
 
Old 07-21-2012, 05:48 AM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Did you check whether the SSH daemon is running?
 
Old 07-21-2012, 08:25 AM   #5
sharadchhetri
Member
 
Registered: Aug 2008
Location: INDIA
Distribution: Redhat,Debian,Suse,Windows
Posts: 179

Rep: Reputation: 23
Quote:
Originally Posted by Nylex View Post
Did you check whether the SSH daemon is running?
do cat /etc/hosts

find the hostname

if localhost is written.Use that ip address.
then do ssh ip_address_of_localhost
 
Old 07-22-2012, 07:25 AM   #6
Arjun
Member
 
Registered: Feb 2011
Posts: 120

Original Poster
Blog Entries: 2

Rep: Reputation: 0
Ok

I have checked it

SSH was not running

But now i am getting this error on input of this command

sshd 127.0.0.1
Quote:
sshd re-exec requires execution with an absolute path
Now when i did this

/usr/sbin/sshd 127.0.0.1

I got this message

Quote:
Extra argument 127.0.0.1.
What is this ?

Last edited by Arjun; 07-22-2012 at 07:57 AM.
 
Old 07-22-2012, 08:31 AM   #7
tshikose
Member
 
Registered: Apr 2010
Location: Kinshasa, Democratic Republic of Congo
Distribution: RHEL, Fedora, CentOS
Posts: 525

Rep: Reputation: 95
Hi Arjun,

There are two totally different binary sshd (for the server aka dameon) and ssh (for client).
To ensure that the server is running, you should launch something as root

Code:
service sshd status
and look at the output

To connect to your local server from your local client, type (as any user)

Code:
ssh 127.0.0.1
Maybe will need to first search for a tutorial for SSH (just google).
 
Old 07-22-2012, 08:39 AM   #8
Arjun
Member
 
Registered: Feb 2011
Posts: 120

Original Poster
Blog Entries: 2

Rep: Reputation: 0
Quote:
Originally Posted by tshikose View Post
Hi Arjun,

There are two totally different binary sshd (for the server aka dameon) and ssh (for client).
To ensure that the server is running, you should launch something as root

Code:
service sshd status
and look at the output

To connect to your local server from your local client, type (as any user)

Code:
ssh 127.0.0.1
As i input

service sshd status

I got

Code:
sshd: unrecognized service
As i entered

service ssh status

I got

Code:
ssh start/running, process 2958
Seems to be running ,then how can i make it work ?

Quote:
Originally Posted by tshikose View Post
Maybe will need to first search for a tutorial for SSH (just google).
I have already mentioned that i didnt got any tutorial related to ssh on localhost
 
Old 07-22-2012, 09:34 AM   #9
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
Hi

What happens if you
Code:
ssh user@ip-of-host
 
Old 07-22-2012, 11:29 AM   #10
xtpeqii
LQ Newbie
 
Registered: Jul 2012
Location: China
Distribution: CENTOS 7
Posts: 6

Rep: Reputation: Disabled
Cool

Quote:
Originally Posted by Arjun View Post
I have tried this but the output i got is
First do this.

Code:
vi /etc/ssh/sshd_config
Then search for "Port [number]", default is 22.BUT it's ok even if it's not 22. remember this port number.

Second

make sure you get the root previlige, then proceed

Code:
service iptables -A INPUT -p tcp --dport [the number you just remembered] -m state --state NEW -j ACCEPT
then,
Code:
service iptables save
and then

Code:
service iptables restart


it works fine for me, ssh [username]@localhost

also MAKE SURE the user of username really exists on you local machine...

for more reference, please read this article:
http://wiki.centos.org/HowTos/Network/IPTables

PS: if you are totally new to this, it really takes some time ...

Last edited by xtpeqii; 07-22-2012 at 11:34 AM.
 
Old 07-22-2012, 06:49 PM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Try (as root)
Code:
# This shows listening tcp services
netstat -tanp |grep ssh

# Looking for
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

more /etc/ssh/sshd_config
if this is on RHEL/Fedora
 
Old 07-23-2012, 04:56 AM   #12
Arjun
Member
 
Registered: Feb 2011
Posts: 120

Original Poster
Blog Entries: 2

Rep: Reputation: 0
Quote:
Originally Posted by spiky0011 View Post
Hi

What happens if you
Code:
ssh user@ip-of-host
When i do this
ssh root@127.0.0.1

I get this
Code:
Read from socket failed: Connection reset by peer
So when i do this
sshd root@127.0.0.1

I get this
Code:
sshd re-exec requires execution with an absolute path
But when i do this
/usr/sbin/sshd root@127.0.0.1

I gets this message
Code:
Extra argument root@127.0.0.1

Quote:
Originally Posted by xtpeqii View Post
First do this.

Code:
vi /etc/ssh/sshd_config
Then search for "Port [number]", default is 22.BUT it's ok even if it's not 22. remember this port number.

Second

make sure you get the root previlige, then proceed

Code:
service iptables -A INPUT -p tcp --dport [the number you just remembered] -m state --state NEW -j ACCEPT
I am getting this error message on above command
Code:
iptables: unrecognized service
I am running it as root.
 
Old 07-23-2012, 06:07 AM   #13
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Quote:
Originally Posted by Arjun View Post
So when i do this
sshd root@127.0.0.1
As others have mentioned above, "sshd" is the server binary so you'd never try to make an SSH connection using it. "ssh" is the client binary and that's what you use to connect.
 
Old 07-23-2012, 11:14 AM   #14
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
Hi

What is wrong with using the true ip 192.168.xx.xx what ever it is?
Or am I missing something.

I cant ssh in using @localhost or 127.0.01 but I can using the ip add @10.42.43.1

Last edited by spiky0011; 07-23-2012 at 11:18 AM.
 
Old 07-23-2012, 07:57 PM   #15
xtpeqii
LQ Newbie
 
Registered: Jul 2012
Location: China
Distribution: CENTOS 7
Posts: 6

Rep: Reputation: Disabled
Quote:
Originally Posted by Arjun View Post
I am new to this.

I want to make connection to localhost via ssh. I have read some tutorials but they were for remote machine & so doesnt working on localhost.

So i want to know that how can i connect to localhost via SSH.

Thanks


COULD YOU provide us the following content:

content in /etc/ssh/sshd_config



THOUGH YOU'D BETTER ASK SOMEONE WHO USE FEDORA in case of some difference between multiple distros.

Last edited by xtpeqii; 07-23-2012 at 08:00 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh: connection to host port: 22: Connection timed out lost connection cucolin@ Linux - Server 4 11-22-2011 06:15 AM
ssh connection forces password change, then closes connection loadedmind Linux - Newbie 2 02-16-2011 01:24 PM
LXer: ssh-xfer: Quickly grabbing files over an existing SSH connection LXer Syndicated Linux News 0 08-08-2008 03:11 PM
ssh connection refused - trying to set up ssh server at home openSauce Linux - Server 10 10-18-2007 04:38 PM
Connection to ssh... wtfn00b Linux - Newbie 2 02-01-2006 10:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration